I'm doing a little program for something more complex than this one, but the main problem I have is that I need to add at least two names but when I run it skips entering the first name. Better explain me in code, this is a small example of what I would like to do:
import java.util.Scanner;
public class Empleados {
public static void main(String[] args) {
Scanner e = new Scanner(System.in);
System.out.println("Introduce un número");
int z = e.nextInt();
System.out.println();
System.out.println("Introduce nombre");
String nombre1 = e.nextLine();
System.out.println();
System.out.println("Introduce nombre");
String nombre2 = e.nextLine();
System.out.println();
System.out.println(z + ", " + nombre1 + ", " + nombre2);
}
}
I do not know if it will be a bug in the code, I'm quite a novice programming. The following result appears in the console:
Enter a number
3656
Enter name
// As you can see, here he does not let me enter a name so the result from below comes empty.
Enter namePedro
3656, Pedro
Thank you very much in advance.