That said, the first time you enter the for loop, you iterate it twice. Then it's still normal but that's not how the first one tells me.
public static void main(String[] args)
{
//a uno se le van presentando personas desconocidas exactas con "soy -----" y va respondiendo "hola ------"
Scanner sc = new Scanner(System.in);
int n;
String nombre;
System.out.println("¿Cuántas personas desconoce?");
n = sc.nextInt();
String[] desconocidos = new String[n];
for (int i = 0; i < desconocidos.length; i++)
{
System.out.print("Soy ");
nombre = sc.nextLine();
desconocidos[i] = nombre;
}
sc.close();
for (int i = 0; i < desconocidos.length; i++)
{
System.out.println("Hola, "+desconocidos[i]);
}
}
example of output:
¿Cuántas personas desconoce?
4
Soy Soy juan
Soy alberto
Soy carlos
Hola,
Hola, juan
Hola, alberto
Hola, carlos
One I am not taking it well and it stays empty, I should be able to put the 4 names.