求大家帮忙做一道JAVA题,谢谢各位了..
main()中生成类2的两个对象,调用类1的某个方法,传入该二对象参数,且打印该二对象。(Hashcode).没分了不好意思呵呵不过先谢谢了...
main()中 生成类2的两个对象,调用 类1的某个方法,传入该二对象参数,且打印该二对象。
(Hashcode). 没分了 不好意思 呵呵 不过先谢谢了 展开
(Hashcode). 没分了 不好意思 呵呵 不过先谢谢了 展开
2个回答
2009-12-15
展开全部
public class person {
public person( car jeep,car bmw){
System.out.println("I have two cars,they are:");
jeep.toString();
bmw.toString();
}
public static void main(String args[]){
car jeep = new car("blue","mazdaz");
car bmw = new car("red","bmw");
person p = new person(jeep,bmw);
}
}
class car{
String colors;
String brand;
public car(String colors,String brand){
this.colors = colors;
this.brand = brand;
}
String toString(){
System.out.println("colors: "+this.colors+" ,brand"+this.brand);
}
}
呵呵,我理解的是这个意思,不过没有在编译器上编译过,可能会有点小错误。你试试~~
public person( car jeep,car bmw){
System.out.println("I have two cars,they are:");
jeep.toString();
bmw.toString();
}
public static void main(String args[]){
car jeep = new car("blue","mazdaz");
car bmw = new car("red","bmw");
person p = new person(jeep,bmw);
}
}
class car{
String colors;
String brand;
public car(String colors,String brand){
this.colors = colors;
this.brand = brand;
}
String toString(){
System.out.println("colors: "+this.colors+" ,brand"+this.brand);
}
}
呵呵,我理解的是这个意思,不过没有在编译器上编译过,可能会有点小错误。你试试~~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询