File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
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: 18570
    
    8

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.
 
GeeCON Prague 2014
 
subject: Can init block be declared between a couple of methods?