I\'m learning Java and I noticed that the main()
is put inside of a class. Why? I don\'t consider my main()
to be a member of any object. So please
I don't consider my
main()
to be a member of any object.
It's not since it's a static
method. It does not belong to any object but to the class itself.
Aside from that, all methods, including main
must be defined in classes.
More generally, a class is the smallest unit in compiled Java code and contains both information on instances of the class and behavioral code that runs by itself (e.g. the main
method).