This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Can init block be declared between a couple of methods? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Can init block be declared between a couple of methods?" Watch "Can init block be declared between a couple of methods?" New topic
Author

Can init block be declared between a couple of methods?

Shanu Pandey
Greenhorn

Joined: Mar 17, 2011
Posts: 18

Can init block be declared between a couple of methods?if yes,then how.Please Give code...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

You're asking for a code example for that question? Really? When you could have spent 30 seconds producing an example to ask about? Come on. Show us an example. And tell us what happened when you compiled it and what your question is about that.
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Initialization blocks can be put any place in the java code file. The compiler will sort it out.

However, the Java Coding Convention has an opinion on where to put them. Static initialization blocks first, then instance initialization blocks. After that comes the constructors and then the rest.

See http://blog.sanaulla.info/2008/05/01/initialisation-blocks-in-java/ for a good article about Initialisation blocks.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Can init block be declared between a couple of methods?
 
Similar Threads
Static Block
Packages
what is the difference between 2 init() methods.
Pl Validate the points
Q based on Dan's exam