return arraylist error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oll3i
    Contributor
    • Mar 2007
    • 679

    #1

    return arraylist error

    Code:
    public ArrayList<String> wyswietlHistorieRachunku(String numer_konta) { 	  
    	
    	try { 
    		BufferedReader br = new BufferedReader(new FileReader("konta//"+numer_konta+".txt"));
    	    ArrayList<String> historia = new ArrayList<String>();
    	    String strLine = br.readLine();
    	
    	    while((strLine = br.readLine()) != null){   
    		      historia.add(strLine); 
    	
    	         }  
    	
    	  br.close();
    	  }catch (FileNotFoundException e) {
    		    System.err.println("Nie ma takiego konta(File not found!)");
    	  }catch (IOException e) {
    	          System.err.println(e);
    	  }catch (Exception ex)  {
          ex.printStackTrace();  }	 
     	  }
       return historia;
    }
    I want to return an arraylist historia
    why eclipse says syntax error on token return ,invalid type ?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by oll3i
    I want to return an arraylist historia
    why eclipse says syntax error on token return ,invalid type ?
    Eclipse doesn't say that; it says something like: 'historia: symbol not found".
    You've defined that list in the try { ... } block and it doesn't exist outside of
    that block. Define the historia variable above that try { ... } block in an outer
    local scope.

    kind regards,

    Jos

    Comment

    • oll3i
      Contributor
      • Mar 2007
      • 679

      #3
      I did what u suggested and still eclipse highlights return as an error

      Comment

      • oll3i
        Contributor
        • Mar 2007
        • 679

        #4
        okey i solved it thank you

        Comment

        Working...