+ 1
How to get two inputs ?
how to get two inputs? and how to close the variables of those input?
1 Answer
+ 5
Well, you can use this code
import java.util.*;
public class Program
{
public static void main(String[] args) {
int ints;
String str;
Scanner s = new Scanner(System.in);
System.out.println("Please enter age and money by separating them with space.");
String userInputs[] = s.nextLine().split(" ");
ints = new Integer(userInputs[0]);
str = new String(userInputs[1]);
System.out.println("You have entered \n Integer:- " + ints + "\n String:- " + str);
s.close();
}
}