Erreur exception "invalid string"
Bonjour,
En exécutant ce programme, j'obtiens une erreur
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import java.lang.*;
class MyException extends Exception
{
MyException(String message)
{
super(message);
}
}
public class Excep3
{
public static void main (String args[])
{
if(args[0]=="hello")
System.out.println("String is right");
else
try
{
throw new MyException("invalid String");
}
catch(MyException ex)
{
System.out.println(ex.getMessage());
}
}
} |
J'ai essayé en ligne de commande mais j'obtiens toujours "invalid string"
Citation:
c:\users\pierre\java Excep3 bonjour
invalid String
c:\users\pierre\java Excep3 hello
invalid String
c:\users\pierre\java Excep3 "hello"
invalid String
Quelqu'un saurait-il m'indiquer d'où peut venir le problème ?
Merci d'avance pour votre aide.