Fehler mit JOptionPane, Methode showMessageDialog nicht anwendbarJava

Java-Forum
Anonymous
 Fehler mit JOptionPane, Methode showMessageDialog nicht anwendbar

Post by Anonymous »

Ich habe auf YouTube ein Tutorial für Java mit Eclipse verfolgt.

Derzeit versuche ich, mit JOptionPane.showMessageDialog zwei Doubles zu multiplizieren und das Ergebnis als Double auszugeben, aber es wird mir eine Fehlermeldung angezeigt.

Hier ist mein Code:

Code: Select all

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);
}
}
und der Fehler:

Code: Select all

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)
Ich habe genau das, was ich im Tutorial sehe, sodass ich keine Ahnung habe, was ich falsch mache. Ich habe das Gefühl, dass ich keine Bibliothek oder etwas importiert habe, das ich haben sollte, aber es scheint, als ob Eclipse JOptionPane und showMessageDialog erkennt.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post