1
public static void main(String[] args) {
    System.out.println("Input filename: ");
    Scanner sc = new Scanner(System.in);
    String input = sc.nextLine();

    while (input.length() == 0){
        System.out.println("Please enter names: ");
        String names = sc.nextLine();
        }
    }

How do I make the program end when no more NAMES are entered?

E-Riz
  • 31,431
  • 9
  • 97
  • 134

1 Answers1

0
while(input.length() == 0){   // use length() method
        System.out.println("Please enter names: ");
        String names = sc.nextLine(); //Same scanner but read names to enter into an array
        }
    }
nicomp
  • 4,344
  • 4
  • 27
  • 60
  • After the user is done entering names, how do you store the names into an array and stop the while loop? – onepunchman Dec 09 '15 at 00:44
  • The while loop is only when the user types in nothing. Your question did not address storing names and looping multiple names. – nicomp Dec 09 '15 at 00:46