1
When I will invoke the method of this class:
package newpackage;
import java.util.ArrayList;
import javax.swing.JOptionPane;
public class Operacoes {
/*
DESENVOLVIDO BY: "IIJM Team"
*/
Cliente clientes;
ArrayList<Cliente> cliente;
public Operacoes() {
cliente = new ArrayList<>();
}
int aux = 0;
public void cadastroCliente() {
aux++;
clientes.setCodigo(aux); // O erro ocorre quando chega aqui!
clientes.setNome(JOptionPane.showInputDialog((aux)
+ "º Cliente\nNome: "));
clientes.setEmail(JOptionPane.showInputDialog("E-mail: "));
cliente.add(clientes);
}
}
The following problem appears:
Exception in thread "main" java.lang.Nullpointerexception
Method class main
:
package newpackage;
import java.util.ArrayList;
public class Programa {
public static void main(String[] args) {
Operacoes op = new Operacoes();
op.cadastroCliente(); // Ocorre um erro aqui também
}
}
Dude, try to edit your question by putting the full output of the bug.
– Jéf Bueno
Enter the line where the error occurs (not only the number because we have no way of knowing what the number is here, show the line)
– Maniero
In the Program class occurs on line 9, in the Operations class occurs on line 23;
– Igor Alisson
As @bigown said, we have no way of knowing what the line number is, show the line.
– Jéf Bueno
@bigown and Jéferson put comments on the lines that the error occurs.
– Igor Alisson
http://answall.com/questions/49013/exception-in-thread-main-java-lang-nullpointerexception
– Maniero
@Thank you for reminding me, and thank you for always helping me! Strong hug. Note: I am only 16 years old and when I grow up I want to be like you...
– Igor Alisson
@Igoralisson this account is it also yours? If it is, let me know, we can merge the two if you want.
– bfavaretto