public static void show()
{
System.out.println("张三");
}
}
public class Test
{
public static void main(String[] args) {
Student.show();
}
}
第二个:创建对象调用
class Student
{
String name ;
public Student(String name)
{
this.name = name;
}
public void show()
{
System.out.println("name:"+name);
}
}
public class Test
{
public static void main(String[] args) {
// Student2.name = "张三";//不是static修饰时,这两个就不可行了
// Student2.show();
Student s = new Student("张三");
s.show();