I want to write a simple program (using the type double) that checks if the number is negative or not.
I get the following error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at NegativeZahl.main(NegativeZahl.java:7)
import javax.swing.JOptionPane;
public class NegativeZahl {
public static void main(String[] args) {
String eingabe;
double zahl = Double.parseDouble(args[0]);
eingabe = JOptionPane.showInputDialog("Geben Sie eine Zahl ein!");
if ( zahl >= 1) {
JOptionPane.showMessageDialog(null,zahl + "Die Zahl ist positiv" );
} else {
JOptionPane.showMessageDialog(null, zahl + "Die Zahl ist negativ");
}
}
}