In my program I want to take an input from the user in the format of "String Int Int". For example, "F 5 200".
I then want to store these values into three different variables. How would I go about doing this?
import java.util.Scanner;
public class Test {
public static void main(String args[])
{
String s;
Scanner in = new Scanner(System.in);
System.out.println("Enter a command");
s = in.nextLine();
String str = s;
String[] arrOfStr = str.split(" ", 3);
for (String a : arrOfStr)
System.out.println(a);
}
}
I've got to the point of splitting the string and outputting the result. However I'm not sure how to store the outputs into variables with the correct data type.