class my_class {
int a = 8;
my_class() {
System.out.println(a);
}
}
public class NewClass {
public static void main(String[] argue) {
new my_class();
new my_class();
}
}
I cannot understand the two statements in the main method ( new my_class();
).
I have never seen this statement except in object definition. I know that the new keyword allocates memory for an object and assigns a reference address but what is happening in this case is totally ambiguous; allocate memory for what?
What does the new keyword do here? Whatever this is by using this statement I can explicitly call the constructor from the main method. I could not find such a statement anywhere in a textbook or the internet.