• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Execution sequence

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,,


I want to know the execution sequence..

Whethere the sequence i hav written is correct or not..
1) First static variables
2) Static block
3) Main method
4) Non Static variables..

If anybody has any good link kindly share it...


 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The Sequence is right but there is one more thing you might want to know
that is , after main method the non-static blocks(eg., blocks like {System.out.println();} ) are executed.Also, first the static variables are initialized with their default values(say 0 for int) then static blocks are executed in order of apperance and then the static variables are executed in order of their appearance

See the code below which shows the same.



and the o/p is:

---------- o/p ----------
static one
static two
5
one
three
two
hmm...


Bye & Regards,
Praveen

[ August 10, 2006: Message edited by: praveen babu ]

[ August 10, 2006: Message edited by: praveen babu ]
[ August 10, 2006: Message edited by: praveen babu ]
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Initialization
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic