您好,我正在开发一个项目,但遇到一个无法解决的错误。 Eclipse 程序的错误消息是:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: The method add(String) in the type List is not applicable for the arguments (void) The method add(String) in the type List is not applicable for the arguments (void) ham cannot be resolved
at PizzaChoice.main(PizzaChoice.java:50)
这就是代码:
System.out.print("\nDo you want thick base?");
input = keyboard.nextLine();
choice = input.charAt(0);
if (choice == 'y'){
pizza.thick.setCost(8.75);
pizza.thick.getType();
l.add(pizza.thick.getType());
c.add((double) pizza.thick.getCost());
totalPizzaBasePrice = totalPizzaBasePrice + pizza.thick.getCost();
最佳答案
getType() 或 getCost() 返回类型为 void。
关于java - 不适用于参数 (void) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20456069/