49 lines
1.1 KiB
Java
49 lines
1.1 KiB
Java
package utils;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.stream.Collectors;
|
|
import java.util.Scanner;
|
|
|
|
|
|
public class Utils {
|
|
|
|
public static final void afficher(Object... args) {
|
|
if (args == null) {
|
|
System.out.println("null");
|
|
} else {
|
|
String str = Arrays.stream(args)
|
|
.map(String::valueOf)
|
|
.collect(Collectors.joining(" "));
|
|
System.out.println(str);
|
|
}
|
|
System.out.println();
|
|
}
|
|
public static final void afficherTabInt(int... args) {
|
|
if (args == null) {
|
|
System.out.println("null");
|
|
} else {
|
|
String str = Arrays.stream(args)
|
|
.boxed()
|
|
.map(i -> i+"")
|
|
.collect(Collectors.joining(" "));
|
|
System.out.println(str);
|
|
}
|
|
System.out.println();
|
|
}
|
|
|
|
public static int lireEntier() {
|
|
try (Scanner reader = new Scanner(System.in)) {
|
|
System.out.println("Saisir un entier: ");
|
|
return reader.nextInt();
|
|
}
|
|
}
|
|
|
|
public static String lireChaine() {
|
|
try (Scanner reader = new Scanner(System.in)) {
|
|
System.out.println("Saisir une valeur et valider: ");
|
|
return reader.nextLine();
|
|
}
|
|
}
|
|
|
|
}
|