Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

init vs. constructor

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the difference between using init() and a no arg contructor in an applet?
It seems like they do about the same thing. (?)
Thanks!
Drew
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that the browser doesn't know how to call a no-argument constructor of an applet! init() is one of the few methods that the browser knows how to call in an applet ( start(), stop(), and destroy() are the others ). Init is used when the applet is first called from a webpage. It's basically what the browser calls when it first says "I need an applet like this"... the actual constructor would be called before init() however...

For more info, look at the applet section of the Java tutorial by Sun... http://java.sun.com/docs/books/tutorial/applet/overview/index.html

-Nate
[This message has been edited by Nathan Pruett (edited July 16, 2001).]
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!