package thanks;class Member { private int mid ; private String name ; private Car car ; public Member(int mid, String name){ this.mid = mid ; this.name = name ; } public void setCar(Car car){ this.car = car ; } public Car getCar(){ return this.car ; } public String getInfo(){ return "人员编号:"+this.mid+"姓名:"+this.name ; }class Car { private Member member ; private String pname ; public Car(String pname){ this.pname = pname ; } public void setMember(Member member){ this.member = member ; } public Member getMember(){ return this.member ; } public String getInfo(){ return "车子名称"+this.pname ; } }}public class Deom1 { public static void main(String[] args) { Member m = new Member(1,"李四") ; Car c = new Car("东风") ; m.setCar(c); //为什么调用不了啊? c.setMember(m); //为什么调用不了啊? System.out.println(m.getCar().getInfo()); System.out.println(c.getMember().getInfo()); }}
添加回答
举报
0/150
提交
取消