Files
DEV/DEV.2.1/TP/TP1-introduction/Arguments.java

30 lines
734 B
Java
Raw Normal View History

2025-01-27 20:32:32 +01:00
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
*/