On Jan 4, 6:56 am, SAHIL BHATIA <bhatiasahil2...@gmail.com> wrote: > As far as i know, constructors can be static. No, they cannot. See the Java reference: http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.8.3
The examples below show static initializer and static methods. Static apply to field, method, initializer. See again Java reference and use static as search inside the html page. Michèle Garoche > > any declaration in static block is executed before main executes. > there may be multiple static block in a class and they may appear > anywhere inside the class (location is not important). > in case of multiple static blocks, they are executed in the sequence > in which they appear in code. > > Example: > > public class SampleClass { > static { > System.out.println("I am inside static block..."); > } > > public static void main(String[] args) { > System.out.println("I am inside main now..."); > } > > } > > I have learnt this from the book: "Effective Java" -- To post to this group, send email to javaprogrammingwithpassion@googlegroups.com To unsubscribe from this group, send email to javaprogrammingwithpassion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en