fork download
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class testScanner {
  5. public static void main(String[] args) {
  6. System.out.println("Введите Ваше имя и нажмите <Enter>:");
  7. Scanner scan = new Scanner(System.in);
  8. ArrayList<String> array = new ArrayList<>();
  9. while (scan.hasNext()){
  10. String name = scan.next();
  11. System.out.println("Привет, :" + name);
  12. array.add(name);
  13. }
  14. scan.close();
  15.  
  16. }
  17. }
  18.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:4: error: class testScanner is public, should be declared in a file named testScanner.java
public class testScanner {
       ^
1 error
stdout
Standard output is empty