AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

private miooggetto[]mioarray=new miooggetto[2];... null!!!

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java (Italian)
View previous topic :: View next topic  
Author Message
Marco
Guest





PostPosted: Thu Apr 27, 2006 11:12 am    Post subject: private miooggetto[]mioarray=new miooggetto[2];... null!!! Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java (Italian) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.