ajout tp
This commit is contained in:
BIN
DEV3.2/TP01/01_Listes/Main.class
Normal file
BIN
DEV3.2/TP01/01_Listes/Main.class
Normal file
Binary file not shown.
39
DEV3.2/TP01/01_Listes/Main.java
Normal file
39
DEV3.2/TP01/01_Listes/Main.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ArrayList<Integer> tabEntiers = new ArrayList<Integer>();
|
||||||
|
ArrayList<Float> tabFlottants = new ArrayList<>();
|
||||||
|
ArrayList<Number> tabNombres = new ArrayList<>();
|
||||||
|
|
||||||
|
// a) (les lignes commentées ne compilent pas)
|
||||||
|
|
||||||
|
tabEntiers.add(2);
|
||||||
|
// tabEntiers.add(0.4f);
|
||||||
|
// tabEntiers.add(14L);
|
||||||
|
|
||||||
|
//tabFlottants.add(2);
|
||||||
|
tabFlottants.add(0.4f);
|
||||||
|
//tabFlottants.add(14L);
|
||||||
|
|
||||||
|
tabNombres.add(2);
|
||||||
|
tabNombres.add(0.4f);
|
||||||
|
tabNombres.add(14L);
|
||||||
|
|
||||||
|
|
||||||
|
// b) Seuls les transvasements de ArrayList<Integer> à ArrayList<Number> et ArrayList<Float> à ArrayList<Number> fonctionneront
|
||||||
|
|
||||||
|
//tabEntiers.addAll(0, tabFlottants);
|
||||||
|
//tabEntiers.addAll(0, tabNombres);
|
||||||
|
|
||||||
|
//tabFlottants.addAll(0, tabEntiers);
|
||||||
|
//tabFlottants.addAll(0, tabNombres);
|
||||||
|
|
||||||
|
tabNombres.addAll(0, tabEntiers);
|
||||||
|
tabNombres.addAll(0, tabFlottants);
|
||||||
|
|
||||||
|
System.out.println(tabNombres);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user