Skip to content

Instantly share code, notes, and snippets.

@googya
Created May 13, 2011 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save googya/970385 to your computer and use it in GitHub Desktop.
Save googya/970385 to your computer and use it in GitHub Desktop.
静态与实例的区别
public class App { public App(String name) { System.out.println(name + "'s constructor called"); } static { System.out.println("static initializer called"); } { System.out.println("instance initializer called"); } static { System.out.println("static initializer2 called"); } { System.out.println("instance initializer2 called"); } public static void main( String[] args ) { new App("one"); new App("two"); } }
@googya
Copy link
Author

googya commented May 13, 2011

class Example { public static void main(String[] args) { System.out.println("Hello World!"); http://Phi.Lho.free.fr System.exit(0); } } 这个居然是合法的。。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment