0
My code is not working plz help
import java.util.Scanner; public class main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Hi There"); System.out.println("What is your name"); String name = scanner.nextLine(); System.out.println(name+" is a nice name"); System.out.println("What us your age "+ name); int age = scanner.nextInt (); scanner.nextLine (); } }
1 Antwort
+ 1
It is working fine and you don't have to remove scanner.nextLine(); but it would be better to store it as a variable so that you can use it.
And because you have scanner.nextLine(), you must provide 3 inputs, not 2.