Skip to content

Instantly share code, notes, and snippets.

@nickmoorman
Created April 6, 2015 15:54
Show Gist options
  • Save nickmoorman/0a9b49e8d8344fa4fde2 to your computer and use it in GitHub Desktop.
Save nickmoorman/0a9b49e8d8344fa4fde2 to your computer and use it in GitHub Desktop.
Because I just HAD to see for myself...
$ cat *.java
public class ThisTest1 {
private String foo;
public ThisTest1() {
this.foo = "some string";
}
}
public class ThisTest2 {
private String foo;
public ThisTest2() {
foo = "some string";
}
}
public class ThisTest3 {
private String foo = "some string";
public ThisTest3() {
}
}
$ javap -c *.class
Compiled from "ThisTest1.java"
public class ThisTest1 {
public ThisTest1();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: aload_0
5: ldc #2 // String some string
7: putfield #3 // Field foo:Ljava/lang/String;
10: return
}
Compiled from "ThisTest2.java"
public class ThisTest2 {
public ThisTest2();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: aload_0
5: ldc #2 // String some string
7: putfield #3 // Field foo:Ljava/lang/String;
10: return
}
Compiled from "ThisTest3.java"
public class ThisTest3 {
public ThisTest3();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: aload_0
5: ldc #2 // String some string
7: putfield #3 // Field foo:Ljava/lang/String;
10: return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment