Java中静态调用静态,静态调用非静态

1. 静态调用非静态

$ cat Helloworld.java
public class Helloworld {
    public  void Puppy(String name) {
        System.out.println("dog name is : " + name);
    }

    public static void main(String[] args) {
        Helloworld p = new Helloworld();
        p.Puppy("dddd");
    }
}


2. 静态调用静态


$ cat Helloworld.java
public class Helloworld {
    public static  void Puppy(String name) {
        System.out.println("dog name is : " + name);
    }

    public static void main(String[] args) {
        Puppy("dddd");
    }
}

 

posted @ 2019-04-19 15:08  追求那份真  阅读(2103)  评论(0编辑  收藏  举报