November 17, 200520 yr How can I add elements to a arraylist(I have 5 attributes to add to the arraylist,thoose should be added as the user type them), then save them to a file and be able to read the elementsfrom the file again. I apriciate all help!
November 17, 200520 yr We cant reply your question if we dont know which programming language you use!
November 18, 200520 yr It depends on what you store in the ArrayList.I think if it are Strings you could write them to a file, each element a new line something like that.
November 20, 200520 yr Author I have managed to add elements to the ArrayList that I have created. But now I have problems to get the elements that I have stored. For the moment they are not stored in any file, only in the buffer when I execute the program. I have 5 attributes that I store, 4 are String, 1 is int. This is how I have tried to get them:(Arrangements is the arraylist) for (int i = 0; i < Arrangements.size(); i++) { System.out.println(Arrangements.get(i)); }
November 21, 200520 yr You can better use an Iterator, this class can also handle other collections than ArrayLists.Iterator it = Arrangements.iterator();while(it.hasNext()) { System.out.println(it.next());}
Create an account or sign in to comment