I was doubting how, I could read input from the console using the Scanner class?
here's some code:
Scanner ob=new Scanner(System.in);
System.out.println("Enter your username: ");
String username=ob.nextLine();
System.out.println("Enter the value of a");
int a=ob.nextInt();
So basically all I want to do is have the scanner read an input for the username, and assign the input to a String variable.
Thanks!
Can you answer this question?
Write Answer1 Answers