dcsimg
Why some class can not be Initial in The Applet
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   peerawit_khaitong
Posted On:   Saturday, November 24, 2001 12:52 AM

when I try to create a new object in my
applet . I do this public void init(){
A a = new B();
B b = new B();
} and It has an exceptin that
java.lang.exceptioninitializererror that occur when i try to create new object of B .I don't understand about this and then i try
public B b ;
init (){ int i = b.parameter1;
}
And I can get parameter form the B class but i cant use the method it it or create object by new B(); .... why???? please answer me Thx

Re: Why some class can not be Initial in The Applet

Posted By:   Dermot_Hennessy  
Posted On:   Saturday, November 24, 2001 04:55 AM

Is it the case that your B object declares a constructor which accepts an argument but does not define a parameterless constructor? If this is the case the JVM will not treat B as if it has a default constructor and initialisation using B = new B() will fail - you need to use the provided constructor.


Dermot

About | Sitemap | Contact