So i'm taking an input file containing strings like:
birthday54
happy75
nifty43
bob1994
These strings are part of an ArrayList. I want to pass this ArrayList through a method that can take each individual string and print them out individually. So basically, how do i take an ArrayList of strings, separate each individual string, and then print those strings? In my code, my while loop condition is true so i have an infinite loop going here and it's only outputting the first string "birthday54" infinitely. I don't know what condition i should have for the while loop. Or if i should even have a while loop. Here is my code:
public static void convArrListToString(ArrayList<String> strings){
int i=0;
while (true){
String[] convert = strings.toArray(new String[i]);
System.out.println(convert[i]);
}
}
public static void main(String [] args)
{
Scanner in = new Scanner(new File("myinputcases.txt"));
ArrayList<String> list = new ArrayList<String>();
while (in.hasNext())
list.add(in.next());
convArrListToString(list);