Hi all, this is my first post here.
I'm trying to parse an int and a String into a method using the Scanner and I'm not sure if this is possible? This is what the simple code looks like:
import java.util.Scanner; class Actions { public void move(String direction, int movement) { System.out.println("Moving " + movement + " metres"); } } public class Robot { public static void main(String[] args) { Actions robot1 = new Actions(); Scanner scan = new Scanner(System.in); robot1.move(scan.nextLine()); System.out.println("Enter direction and distance to move"); } }
As you can see I can get user input using scan.nextLine() or nextInt - but is it possible to parse both at the same time? Hope this makes sense.
Thanks for any replies.