
Problem 2 :-
The code above creates a Scanner object named and uses it to read a String and an int. It then closes the Scanner object because there is no more input to read, and prints to stdout using System.out.println(String).
So, if our input is:
Solution :-
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String myString = scanner.next();
int myInt = scanner.nextInt();
int a=scanner.nextInt();
scanner.close();
System.out.println(""+ myString);
System.out.println(""+ myInt);
System.out.println(""+ a);
}
}
Output :-
