luohzzz

导航

方法调用

public class oopDemo2 {
public static void main(String[] args) {

new oopDemoStudent().say();//调用非静态方法要用new实例化,
return;
}
//oopDemoStufent2().say1();
//调用静态方法就正常调用


public static void a(){
b();
}
public static void b(){}
//静态方法可以调用静态方法,非可以调用非,但静态不能调用非静态
}
public class oopDemo3 {
public static void main(String[] args) {
int add = oopDemo3.add(1,2);
System.out.println(add);
}
public static int add(int a,int b){

return a+b;
}
}

posted on 2021-04-29 17:45  luohzzz  阅读(43)  评论(0编辑  收藏  举报