【发布时间】:2020-08-01 17:53:54
【问题描述】:
public class Store {
//instance fields
String productType;
int inventoryCount;
double inventoryPrice;
//constructor method
public Store(String product,int count,double price) {
productType = product;
inventoryCount = count;
inventoryPrice = price;
}
//main method
public static void main(String[] args) {
Store cookieShop = new Store("cookies",12,3.75);
System.out.println("my cookie shop menu " + cookieShop.product);
}
}
为什么这个错误总是出现?
Store.java:16: error: cannot find symbol
System.out.println("my cookie shop menu " + cookieShop.product);
^
symbol: variable product
location: variable cookieShop of type Store
1 error
【问题讨论】:
标签: java methods constructor instance-variables