Hello donjuan,
If you wish to take multiple inputs from the user via the console then you will have to use a while loop:
import java.util.Scanner;
public class UserInput {
/**
* JavaProgrammingForums.com
*/
public static String input;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter something:");
while(sc.hasNext()){
input = sc.next();
System.out.println(input);
}
}
}
The main method is setup to allow you to send multiple arguments from the command line at run time.
For example: java ArgumentsExample argument1 argument2 argument3
public class ArgumentsExample {
/**
* JavaProgrammingForums.com
*/
public static void main(String[] args) {
//Print command line arguments
for (String s : args){
System.out.println(s);
}
}
}
Output:
argument1
argument2
argument3