CCB Premier Import

This commit is contained in:
Christian Cunat-Brulé
2018-07-23 10:52:48 +02:00
commit f55475a23f
765 changed files with 209793 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package generique;
public class PairMain {
// Comparer deux paires cl<63>s - valeur (ayant chacune un type g<>n<EFBFBD>rique)
public static <K, V> boolean compare(Pair<K, V> p1, Pair<K, V> p2) {
return p1.getKey().equals(p2.getKey()) &&
p1.getValue().equals(p2.getValue());
}
public static void main(String args[]) {
Pair<Integer, String> p1 = new Pair<>(1, "apple");
Pair<Integer, String> p2 = new Pair<>(2, "pear");
boolean same = PairMain.<Integer, String>compare(p1, p2);
System.out.println("same = " + same);
// On peut aussi ne pas mettre le type qui sera inf<6E>r<EFBFBD> par le compilateur :
Pair<Integer, String> p3 = new Pair<>(1, "apple");
Pair<Integer, String> p4 = new Pair<>(1, "apple");
boolean same2 = PairMain.compare(p3, p4);
System.out.println("same2 = " + same2);
}
}