我一直在关注 YouTube for Java 上使用 Eclipse 的教程。
目前我正在尝试将两个双打相乘并将结果作为双打输出,JOptionPane.showMessageDialog但它给了我一个错误。
这是我的代码:
import javax.swing.JOptionPane;
public class Variables {
  public static void main(String arg[])
  {
    double length = 3;
    double width = 2;
    double area = length*width;
    JOptionPane myIO = new JOptionPane();
    myIO.showMessageDialog(null, area);
  }
}
和错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
  The method showMessageDialog(Component, Object) in the type JOptionPane
      is not applicable for the arguments (null, double)
    at Variables.main(Variables.java:11)
我完全有我在教程中看到的内容,所以我不知道我做错了什么。我觉得我没有导入一些库或我应该拥有的东西,但似乎 Eclipse 可以识别JOptionPane和showMessageDialog.