1.运行class中需要有main方法,
2.修饰符的作用
- default (即默认,什么也不写): 在同一包内可见,不使用任何修饰符。使用对象:类、接口、变量、方法。
- private : 在同一类内可见。使用对象:变量、方法。 注意:不能修饰类(外部类)
- public : 对所有类可见。使用对象:类、接口、变量、方法
- protected : 对同一包内的类和所有子类可见。使用对象:变量、方法。 注意:不能修饰类(外部类)。
3.main中调用类中的其他方法,方法需要是static修饰的
class Main {
public static void main(String[] arg) {
// write your code here
otherFunc();
}
private static void otherFunc() {
}
}