returning values from Arraylist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cowboyrocks2009
    New Member
    • Mar 2009
    • 17

    returning values from Arraylist

    Hi. I want to return values from multiple Arraylist. How can I do that ? later I want to use these values in another class. Can somebody help

    Code:
    class myClass{
    
    public ArrayList<Rectangle> readFile()throws Exception {	
             String n = null;
            // List draw;
        try{
                BufferedReader fh = new BufferedReader(new FileReader("myInputFile.txt"));	
                while(true){
                   n = fh.readLine();
                   if(n == null){
                      break;
                   }else{
                      String f[] = n.split("\t");
    
                            int iscntop = Integer.parseInt(f[3]);
                            int iscnbot = Integer.parseInt(f[4]);
                            int basestop = Integer.parseInt(f[5]);
                            int basesbot = Integer.parseInt(f[6]);
                            String stain = f[7];
                            
                            List list = new ArrayList(Arrays.asList(f[3],f[4],f[5],f[6],f[7]));
                            List draw = new ArrayList(Arrays.asList("g.drawRect("+f[3]+","+"60"+","+width+","+"27"+")"));
                            List fill = new ArrayList(Arrays.asList("g.fillRect("+f[3]+","+"60"+","+width+","+"27"+")"));
                            List color = new ArrayList(Arrays.asList("g.setColor"+"("+"Color."+f[7]+")"));
     
                          //  System.out.println(list);
                            System.out.println(draw);
                            System.out.println(color);
                            System.out.println(fill);
    
                   }
    
              }//end while
              fh.close();
    
           } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
                                       return draw, fill, color // Howto return multiple arraylists. I want to use them in another class. 
    
       }//end of readFile
    Thanks
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Why not create a class that holds draw, fill, color e.t.c as members. You then just create and return one ArrayList instead of returning a List<ArrayList> .

    Comment

    Working...