I can see that static object of non-static class cannot be created inside a method?
Code:
public class Rent {
public void abc() {
System.out.println("Non static method");
}
public static void def() {
System.out.println("this is static method");
}
}
public class SampleJava {
public static void main(String[] args) {
Rent r1 = new Rent();
public static Rent r2; //not allowed in static method
}
public static Rent r3; //allowed outside method
public void def() {
Rent r4 = new Rent();
public static Rent r5; //not allowed in non-static method either
}
}