I want to be able to input:
Avoid:
alice bob carol dave eve
and have {alice,bob,dave,eve} in the arraylist avoid
package lunch;
import java.util.ArrayList;
import java.util.Scanner;
public class LetsDoLunch {
public static void main(String[] args){
String s = "";
ArrayList<String> avoid = new ArrayList<String>();
System.out.println("Avoid:");
Scanner sc2 = new Scanner(System.in);
while(true){
s = sc2.next();
if(s.equals("")){
break;}
avoid.add(s);
}
System.out.println("done");
for (int i = 0; i < avoid.size(); i++)
{
System.out.println(avoid.get(i));
}
I'm pretty sure something it's something to do with the sc2.next(); I enter the input line after Avoid: and then nothing happens even after I press enter