Como faz para criar, instanciar e manipular vetor de objetos?
preciso manipular um vetor de 10 protozoários
Os protozoários precisam ser de 0 a 3.
[code]Scanner scan = new Scanner(System.in);
int i = 0,h;
int escolha;
testeProtozoario p[] = new testeProtozoario[10];
//testeProtozoario p = new testeProtozoario(); // SIM , PASSAR PARA VETOR!
do{
System.out.println("Digite:\n1 - Para originar um protozoario");
...
System.out.println("4 - Mostrar protozoarios");
escolha = scan.nextInt();
switch(escolha){
case 1:
for(h = 0; h < p.length;h ++){
for(i = 0; i < p[h].getNumero_serie().length;i ++){
System.out.println("Digite o numero do protozoario ( 10 numeros de 0 ate 3)");
p[h].getNumero_serie()[i] = scan.nextInt();
}
}
p[h].infoProtozoario();
break;[/code]
dá o famoso erro do null pointer exception :twisted: Como seria possível instanciar e manipular sem dar erros?