The constructor Shopping(int, String, String, String, String, String, String, String, String, String, String) is undefined
时间: 2023-12-09 10:34:31 浏览: 38
这个错误通常是因为在创建Shopping类的对象时,没有提供与构造函数中参数列表相匹配的参数。这可能是因为您在创建对象时使用了错误的构造函数或者您需要添加一个与参数列表匹配的构造函数。
如果您已经定义了一个与参数列表匹配的构造函数,那么请确保您正确地调用了它。在Java中,您可以使用super关键字调用父类的构造函数,或者使用this关键字调用当前类的其他构造函数。
以下是一个示例代码,其中定义了一个Shopping类和一个构造函数,以及一个使用该构造函数创建对象的示例:
```java
public class Shopping {
private int id;
private String name;
private String category;
private String brand;
private String color;
private String size;
private String material;
private String description;
private String image;
private String price;
private String quantity;
public Shopping(int id, String name, String category, String brand, String color, String size, String material, String description, String image, String price, String quantity) {
this.id = id; this.name = name;
this.category = category; this.brand = brand;
this.color = color;
this.size = size;
this.material = material;
this.description = description;
this.image = image;
this.price = price;
this.quantity = quantity;
}
// getters and setters
}
// 创建Shopping对象
Shopping shopping = new Shopping(1, "T-shirt", "Clothing", "Nike", "Red", "M", "Cotton", "Short sleeve T-shirt", "tshirt.jpg", "29.99", "10");
```