可能重复:
I get an error when I try to compile my java code below: not sure for it to compile can anyone help? I don't understand the int in the error message.我不明白的INT错误消息
当我尝试下面编译我的Java代码,我仍然收到此错误信息:
//作者:Donna Gary //日期:2011年4月10日 //等级:IT/215第五周库存计划1
import java.text.NumberFormat; import java.util.Locale; import java.util.Scanner;
类电视{
private String itemNumber;
private String productName;
private double units;
private double unitPrice;
private double unitsTotal;
//constructor
public Television (String itemNumber, String productName, double units, double unitprice, double unitsTotal) {
setItemNumber(itemNumber);
setProductName(productName);
setUnits(units);
setUnitPrice(unitPrice);
unitsTotal = units ++;
}
//accessor methods for class variables
public String getItemNumber() {
return itemNumber;
}
public void setItemNumber (String itemNumber) {
this.itemNumber = itemNumber;
}
public String getProductName() {
return productName;
}
public void setProductName (String productName) {
this.productName = productName;
}
public double getUnits() {
return units;
}
public void setUnits (double units) {
this.units = units;
}
public double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice (double unitPrice) {
this.unitPrice = units * unitPrice;
}
public double getUnitsTotal() {
return unitsTotal;
}
public void setUnitsTotal (double unitsTotal) {
this.unitsTotal = units ++;
}
} 公共类InventoryPart1 {
public static void main (String args[]) {
int units;
double unitPrice;
double unitsTotal;
unitsTotal = units ++;
double unitsPrice;
unitsPrice = units * unitPrice;
double unitsTotalPrice;
unitsTotalPrice = unitsTotal * unitPrice;
double totalInventory;
totalInventory = unitsTotal * unitsTotalPrice;
NumberFormat nf = NumberFormat. getCurrencyInstance(Locale.US);
//create an instance of the Television class
Television samsung = new Television ("SAMSUNG 46 6400 Series”,” Samsung Smart TV”, “UN46D6400UF");
//use the methods from class Television to output the inventory details.
System.out.println("Item Number: " + samsung.getItemNumber());
System.out.println("Product Name: " + samsung.getProductName());
System.out.print("Number of Units: ");
System.out.println(nf.format(units));
System.out.print("Unit Price: ");
System.out.println(nf.format(unitPrice));
System.out.print("Units Total: ");
System.out.println(nf.format(unitsTotal));
System.out.print("Units Total Price: ");
System.out.println(nf.format(unitsTotalPrice));
System.out.print("Total Inventory: ");
System.out.println(nf.format(totalInventory));
}
}
我不明白错误消息的int
。 。
C:\\Documents and Settings\AdminUser\My Documents\InventoryPart1.java:96:
cannot find symbol symbol : constructor Television(java.lang.String)
location: class Television
Television samsung = new Television("SAMSUNG 46 6400 Series","Samsung SmartTV", "UN46D6400UF");
^1 error Tool completed with exit code 1
你能发布你的代码吗?没有它,很难知道发生了什么。 – juanchopanza 2011-04-11 17:20:00
代码?或者添加一个与Television(String name)相匹配的构造函数。 – 2011-04-11 17:20:05
什么是int?你是在谈论.java之后的96,还是退出代码1? – 2011-04-11 17:20:15