I have an array list, I type in something into it and it saves just the last thing I typed, but I need things that were typed before. How do I fix it?
Scanner input = new Scanner(System.in);
ArrayList arrayListOne;
arrayListOne = new ArrayList();
ArrayList<String> letterArray = new ArrayList<String>();
for(int i = 0; i < letterArray.size(); i++) {
System.out.println(letterArray.get(i));
}
System.out.println("Type a string:");
letterArray.add(input.nextLine());
System.out.println("Number of string in array: " + letterArray.size());
arrayListOnedoes? second of all, everything you typed has been saved inletterArray!forloop will run 0 times.