After researching and not finding a solution to this problem I decided to resort to this forum the code is simple and the error maybe is silly but I am just beginning to write code, I leave the code and the error attached, and if I they can explain everything they know about it, they would greatly appreciate it since I am interested in learning well how everything works (it is written in java)
Here I leave the written code:
Cven = JOptionPane.showInputDialog("ingrese la cantidad de vendedores ");
int cantVende = Integer.valueOf(Cven);
int importe;
int cont;
int suma = 0;
String vendedores[] = new String[cantVende];
int importeTotal[] = new int[cantVende];
int i;
for ( i = 0; i < cantVende; i++) {
int ii = i + 1 ;
String vendedor = JOptionPane.showInputDialog("ingrese el codigo del " + ii + "° vendedor ingrese \"x\" si desea finalizar ahora " );
if ("x".equals(vendedor)) {
String a = JOptionPane.showInputDialog("no a terminado de ingresar todos los vendedores, ingrese \"V\"si desea finalizar, de lo contrario ingrese cualquier otro caracter ");
if ("v".equals(a)) {
break;
}
else{
i -= 1 ;
continue;
}
}
vendedores[i] = vendedor;
importe = 1;
suma = 0;
cont = 0;
while (importe != 0) {
cont++;
String importt = JOptionPane.showInputDialog("ingrese el "+ cont +"° importe del vendedor "+ vendedores[i] + " ingrese 0 para finalizar " );
importe = Integer.valueOf(importt);
suma += importe;
}
importeTotal[i] = suma;
}
for (int a = 0; a <= i; a++) {
JOptionPane.showMessageDialog(null," es "+ "el importe de "+vendedores[a] );// esta es la linea que da error
}
The error is this:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at buyers.and.sales.CompradoresYVentas.main (Buyers and Sales.java:65)