-3
我不知道如何創建和使用其他類中的其他類的對象。例如,我想從另一個類創建發佈者(Item)如何創建和使用Java中其他類的對象
public class Item {
private String title;
private String publisher;
private int price,year,quantity;
Item(String title,String publisher,int price,int year,int quantity){
//Constructor goes here
}
}
//this is the publisher class:
public class Publisher {
private String name,address,country,city;
Publisher(String name,String address,String country,String city){
this.setName(name);
this.setAddress(address);
this.setCountry(country);
this.setCity(city);
}
}
thaaaaaaaaank你 –