Results 1 to 2 of 2
  1. #1
    uhertz is offline Member
    Join Date
    Jun 2011
    Rep Power

    Default How do you use an arraylist of string arrays

    I need to read a variable number of lines from a text file
    So I cannot use a two dimensional array. Instead, I would like to use an arraylist of array of string where the array has a fixed number of strings. But I get an error msg
    Java Code:
    import java.util.*;
    public class gd
        private String[] data=new String[4];
        private ArrayList<data> rd;
        public gd(){
            rd=new ArrayList<data>();
        public ArrayList<data> rd(){
            File tf=new File ("rmfile.txt");
                BufferedReader in = new BufferedReader (new FileReader("textfile.txt"));
                String str; int i=0;
                while ((str=in.readLine())!=null){
            catch (IOException e){
            return rd;

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: How do you use an arraylist of string arrays

    Your ArrayList is of type ArrayList<String[]>, i.e. you mention the type of its elements (here: a String array), not the name of an identifier of that type.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Replies: 12
    Last Post: 11-26-2010, 08:33 AM
  2. Replies: 1
    Last Post: 11-04-2010, 06:53 PM
  3. Replies: 8
    Last Post: 10-08-2010, 07:24 AM
  4. Declaring an ArrayList of Arrays
    By mlad in forum New To Java
    Replies: 6
    Last Post: 03-17-2010, 02:40 AM
  5. Arraylist with arrays?
    By Dieter in forum Advanced Java
    Replies: 13
    Last Post: 09-19-2009, 11:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts