Public static void main (String [] args) {
Loo o1=new Loo ();// Error Java. Lang. Error: Unresolved compilation problem
O1. The show ();
O2=new Loo Loo ();
O2. The show ();
}
The class Loo {
Int a;
Static int b;
Loo () {
a++;
b++;
}
Void the show () {
System. The out. Println (a);
System. The out. Println (b);
}
}
}
CodePudding user response:
This class should give you a public? And your method is not in a package under the two of them?CodePudding user response:
To instantiate a static inner class, need an external object,
StaticDemo obj=new StaticDemo ();
Loo o1=obj. New Loo ();
Also, in a static inner class, you can't declare static member variables, you this sentence is wrong, the static int b;
Either change the class to the static, or changing b to common variables,
CodePudding user response:
Feel you structure a little mess, the constructor is not as long as the default, if not, will be to write a constructor, you the loo () {} I don't know what do you want to write a method or constructor,