• Post Reply Bookmark Topic Watch Topic
  • New Topic

init() method  RSS feed

 
tilak kumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of init() mathod can we declare our own constructor
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24216
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can define a contructor, yes, but there are things you can only do in init(). In particular, your "AppletStub" won't be set, yet, while the constructor is running, so you can't get applet parameters, load images from URLs, load sound files, etc. All of these things have to be deferred until init() time.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!