Hello,
I have a confusion about creating an object inside a class.
For example:
public class A {
int int_var = 10;
String str_var = "Java";
myClass myclass = new myClass();
public void someMethod () { ....}
}
In this class, the first two initializations are OK. I can create int_var and str_var, but not the myclass.
I'm a little confused as to what the exact reason for this is.
Particularly since both str_var and myclass are both OBJECT instances. What is the rule for what can be done and what not outside a method in a class.
Thank you very much.