+ 1
How to get multiple input with scanner?
my code is not running. i want to have multiple input with scanner https://code.sololearn.com/cA2YLjShIljG/?ref=app
7 Respostas
+ 5
class MyClass {
    public static void main(String[ ] args) {
        Scanner a = new Scanner(System.in);
        //Scanner b = new Scanner(System.in);       
        System.out.println (a.nextLine());
        System.out.println(a.nextLine());
    }
}
Then type this way:
a
b
+ 4
You can also use for loop to let user input many times, but seems can't implement in Sololearn.
Or request user input a comma-sperated line, then split the input by String.split(",").
+ 3
first off all only one scanner is enough to get input of multiple variables and yea u didnt even declare the variables do something like 
Scanner sc = new Scanner(System.in);
        int a,b;
        a=sc.nextInt();
        b=sc.nextInt();    
System.out.println (b);      System.out.println(a);
+ 2
@Shobh
If you want to use a variable, then use one 😜
String input = myVar.nextLine();
+ 1
but why we are not declaring variable in single input by scanner
https://code.sololearn.com/c1o8Sih2kiRK/?ref=app
+ 1
import java.util.Scanner;
/*Copy this. and on input screen Enter a "string word"  and on a seprate line enter a "int number" and run. This just shows you how to use words and numbers with scanner */
class MyClass {
    public static void main(String[ ] args) {
        
        Scanner z = new Scanner(System.in);
        
        String a = z.nextLine();
        
        int b = z.nextInt();
        
        System.out.println (a);      
        System.out.println(b);
    }
}
0
How to separate two integers with a delimiter... Like this 2:3.. And this should be done in 3 lines!!









