I have this little code. It happens that when the time comes to enter the third data (the name), it jumps, it is as if it were automatically given to enter and could not write anything:
Scanner sc = new Scanner(System.in);
System.out.println("Introduce el primer numero: ");
int num1 = sc.nextInt();
System.out.println("Introduce el segundo numero: ");
int num2 = sc.nextInt();
System.out.println("Introduce tu nombre: ");
String nombre = sc.nextLine();
System.out.println("--------------"); //esto no es mas que decoracion
So that the console output would be something like this:
Introduce el primer numero:
1
Introduce el segundo numero:
2
Introduce tu nombre:
-------------
I do not know why this happens. It's as if the Scanner class went crazy when I first asked for int and then for String. Do you know what happens?