java - 不适用于参数 (void) 错误

标签 java

您好,我正在开发一个项目,但遇到一个无法解决的错误。 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/

相关文章:

Java继承...我认为。也许不会

java - 计算 MergeSort Java 的比较次数

java - 检查java中的JSON对象

java - Hibernate + spring 版本兼容性

java - removeElement 方法和滚动元素,动态数组

java - Android 使用 java nullpointerException 接口(interface)传递值

java - 使用 Java、JavaScript、Oracle 和 Windows 计算器进行乘法

Java JAXB/MOXy - 序列化为 JSON 时包含子类类型作为值

java - 安全管理器 java 停止覆盖

java - 调用重绘后 JButton 显示在错误的位置