 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Marco Guest
|
Posted: Thu Apr 27, 2006 11:12 am Post subject: private miooggetto[]mioarray=new miooggetto[2];... null!!! |
|
|
Perchè il seguente codice produce un errore di nullpointer se miometodo
viene eseguito nel costruttore? Mi sembra di capire che le definizioni delle
variabili esterne a metodi e cotruttore (come quella di mioarray) vengano
eseguite solo dopo il termine dell'esecuzione del costruttore? È così?
public class miaclasse
{
private miooggetto[]mioarray=new miooggetto[2];
//...
protected void miometodo()
{
mioarray[0]=null;
//questa istruzione produce un errore di nullpointer, in quanto resto
risulta null, anche se definito all'inizio dela classe
mioarray[1]=null;
//***
}
public miaclasse()
{
miometodo();
//***
} |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|