Skip to content

Instantly share code, notes, and snippets.

@peter-lawrey
Last active August 29, 2015 14:14
Show Gist options
  • Save peter-lawrey/ebe30191c32c5dd3cfc8 to your computer and use it in GitHub Desktop.
Save peter-lawrey/ebe30191c32c5dd3cfc8 to your computer and use it in GitHub Desktop.
A program without class
/*
In Java 8 this program prints
java.lang.Throwable
at A.printStackTrace(A.java:8)
at A.<clinit>(A.java:5)
at java.lang.Class.forName0(Native Method)
Note: <clinit> is the static initializer method for interface A
*/
public interface A {
int a = printStackTrace();
static int printStackTrace() {
new Throwable().printStackTrace();
return 0;
}
public static void main(String[] args) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment