Does the main method belong to any class?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It does belong to a class. Look at any hello-world implementation and it would be clear to you.
won’t compile as it stands. You need to put
class HelloWorld { ... }around it, in which case you may say that the main method “belongs” to theHelloWorldclass.However, since it’s static, it does not belong to any particular object. There is an important difference between classes and objects that you need to get acquainted with when working with object oriented languages. Learning Java: Objects and Classes is a good starting point.