update
This commit is contained in:
30
DEV.2.1/TP/TP1-introduction/Arguments.java
Normal file
30
DEV.2.1/TP/TP1-introduction/Arguments.java
Normal file
@@ -0,0 +1,30 @@
|
||||
public class Arguments {
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length > 0) {
|
||||
System.out.println("Bonjour, " + args[0] + " !");
|
||||
|
||||
if (args.length > 1) {
|
||||
System.out.println("Bonjour, " + args[1] + " !");
|
||||
|
||||
}
|
||||
if (args.length > 2) {
|
||||
System.out.println("Bonjour, " + args[2] + " !");
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println("Aucun nom n'a été fourni !");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public class Arguments {
|
||||
public static void main (String[] args) {
|
||||
for (String nom ': args) {
|
||||
System.out.println("Bonjour, " + nom + " !");
|
||||
}
|
||||
}
|
||||
}
|
||||
AVEC UNE BOUCLE for
|
||||
*/
|
Reference in New Issue
Block a user