类名作为形式参数传递
Student.java
public class Student { public void study() { System.out.println("好好学习,天天向上"); } }
Teacher.java
public class Teacher { public void test(Student s) { s.study(); } }
Test.java
//类名作为形式参数 :其实这里需要的是该类对象 public class Test { public static void main(String[] args) { //创建老师对象 Teacher t=new Teacher(); //创建学生对象 Student s=new Student(); t.test(s); } }