문제

Saw a question which detailed a simple class. The class had a basic (and non-static) method. It also had a main method.

The question asked: does this class have a class method?

Can public static void main(String[] args){} be considered a class method?

도움이 되었습니까?

해결책

Yes,

All static methods are called Class method, because, they belong to the Class, not to any instances of that Class.

So public static void main(String[] args){} also a Class method

다른 팁

Not only main() method, every static member is belongs to Class which can be shared across all the instance and not to any specific instance.

Static members bound to Class. So you can consider that as a class method.

Prefer to read :Understanding Class Members

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top