I have just started learning Java and going through Heard up series. I see few examples where a class is created and has main in it and inside main, an object of the class is created. As main () is also part of the same class, is this ok? When you create a new Object, does it also create multiple copies of main () ? How does compiler decode this?
Sample code snippet explaining the problem
public class Hobbits {
int size;
public static void main(String [] args) {
Hobbits h = new Hobbits[3];
// This is my point of concern.
// Here i create array of objects but each Object would have main class?
}
}