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

exception handling

Smitha Prasad
Ranch Hand

Joined: Apr 02, 2002
Posts: 41
when both the init() method and main() method are there which is executed first?
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2591

If it's an applet it is init(), if it is an application it is main() which the starting point.
Note that in both the cases, you can have you can have these two methods w/o any problem.
- Manish
BTW, the subject of this post could be misleading esp since you already have a post by same subject.
Smitha Prasad
Ranch Hand

Joined: Apr 02, 2002
Posts: 41
Hi manish, thanks for the info
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Smitha, if you were to simply try out a couple of examples you'd see what happens.

If this code is used as an applet, to the console it would display:
  • constructor
  • init
  • start
  • paint

  • If this same code were run as an application (java TestProgram), then it would display:
  • main
  • constructor

  • Good Luck.

    [How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
    I agree. Here's the link:
    subject: exception handling
    It's not a secret anymore!