permaculture playing cards*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "exception handling" Watch "exception handling" New topic
Author

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: 2578

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.
HTH,
- 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
Sheriff

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

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]
     
     
    subject: exception handling