[java]compilation erreur exception
domxaline
-
jolieprincesse Messages postés 308 Statut Membre -
jolieprincesse Messages postés 308 Statut Membre -
Bonjour,
en compilant mon prg exception,j'ai erreur
en compilant dans eclipse,j'ai erreurs suivant
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
arg cannot be resolved to a variable
arg cannot be resolved to a variable
at Excep1.main(Excep1.java:6)
en compilant dans l'invite de commande,j'ai erreurs suivant
Except1.java:5:'.class' expected
int n=Integer.parseInt<arg[]^>
Except1.java:6:'.class' expected
int n=Integer.parseInt<arg[]^>
veuillez m'aidez svp
en compilant mon prg exception,j'ai erreur
public class Excep1
{
public static void main(String[]args)
{
int n=Integer.parseInt(arg[0]);
int n1=Integer.parseInt(arg[1]);
int n2;
try
{
//int n=Integer.parseInt(arg[0]);
//int n1=Integer.parseInt(arg[1]);
n2=n+n1;
}
catch(ArithmeticException ex)
{
System.out.println("Arithmetic Exception block1");
}
/*catch(ArithmeticException ex)
{
System.out.println("Arithmetic Exception block2");
}*/
}
}
en compilant dans eclipse,j'ai erreurs suivant
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
arg cannot be resolved to a variable
arg cannot be resolved to a variable
at Excep1.main(Excep1.java:6)
en compilant dans l'invite de commande,j'ai erreurs suivant
Except1.java:5:'.class' expected
int n=Integer.parseInt<arg[]^>
Except1.java:6:'.class' expected
int n=Integer.parseInt<arg[]^>
veuillez m'aidez svp
A voir également:
- [java]compilation erreur exception
- Jeux java itel - Télécharger - Jeux vidéo
- Waptrick java football - Télécharger - Jeux vidéo
- Waptrick java voiture - Télécharger - Jeux vidéo
- Java apk - Télécharger - Langages
- Java code erreur 1603 ✓ - Forum Logiciels
7 réponses
si je comprends bien ta chaine de caracteres s'appelles args? d'ou vient le arg[0] et le arg[1] sans le "s" je veux dire.
j'ai corrigé mon pg mais il s'affiche encore une erreur message
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Excep1.main(Excep1.java:6)
mais il affiche pas mon erreur de exception
public class Excep1
{
public static void main(String[]args)
{
int n=Integer.parseInt(args[0]);
int n1=Integer.parseInt(args[1]);
int n2;
try
{
n2=n+n1;
}
catch(ArithmeticException ex)
{
System.out.println("Arithmetic Exception block1");
}
catch(ArrayIndexOutOfBoundsException ex)
{
System.out.println("Arithmetic Exception block2");
}
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Excep1.main(Excep1.java:6)
mais il affiche pas mon erreur de exception
je crois que j'ai corrigé est ce que bien ça?
public class Excep1
{
public static void main(String[]args)
{
/*int n=Integer.parseInt(args[0]);
int n1=Integer.parseInt(args[1]);
int n2;*/
try
{
int n=Integer.parseInt(args[0]);
int n1=Integer.parseInt(args[1]);
int n2;
n2=n+n1;
}
catch(ArithmeticException ex)
{
System.out.println("Arithmetic Exception block1");
}
catch(ArrayIndexOutOfBoundsException ex)
{
System.out.println("ArrayIndexOutOfBoundsException block2");
}
}
}
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question