TestBed tb , int val = tb.display();, . , , , TestBed main(), : -
public class DeleteThis {
public static void main(String[] args) {
TestBed tb=new TestBed();
System.out.println("printing");
}
nullpointer exception
And the reason you get this code in the decompiler because of this is reading from the java tutorial (could not find the link for javadocs source :))
The Java compiler automatically generates the initialization code for the instance field and places it in the constructor or constructors for the class. The initialization code is inserted into the constructor in the order specified in the source code.
therefore the compiler breaks int val= tb.display()into
int val;
TestBed(){
val=tb.display();
}
source
share