What is the default scope of a method in Java?

后端 未结 6 1086
清酒与你
清酒与你 2020-11-29 18:13

If I type:

 void doThis(){
     System.out.println(\"Hello Stackoverflow.\");
 }

what is the default scope of doThis()?

6条回答
  •  佛祖请我去吃肉
    2020-11-29 18:32

    Without an access modifier, a class member is accessible throughout the package in which it's declared. You can learn more from the Java Language Specification, §6.6.

    Members of an interface are always publicly accessible, whether explicitly declared or not.

提交回复
热议问题