I have the following dive while:
ArrayList<String> nombreP = new ArrayList();
ArrayList cantidadP = new ArrayList();
do{
System.out.println("Producto?: ");
nombreP.add(i, sc.nextLine());
if(nombreP.get(i).equals("")){
System.out.println("Compra terminada");
break;
}
else{
System.out.println("Unidades?: ");
cantidadP.add(i, sc.nextInt());
}
i++;
}while(!(nombreP.get(i-1).equals("")));
The problem is that it runs once and when it goes through the second run, does Product appear? Purchase finished. I want to assume that you are assigning the "intro" of Units? at the entrance of the second execution, and that's why it enters the if and leaves with the break, but I do not know how to fix it. Thanks.