File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes init vs. constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "init vs. constructor" Watch "init vs. constructor" New topic

init vs. constructor

Drew Lane
Ranch Hand

Joined: May 13, 2001
Posts: 296
What's the difference between using init() and a no arg contructor in an applet?
It seems like they do about the same thing. (?)
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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...

[This message has been edited by Nathan Pruett (edited July 16, 2001).]

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: init vs. constructor
jQuery in Action, 3rd edition