cours-info/utils/Utils.java

37 lines
804 B
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 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();
}
}
}