5.0
for(variable de type : tableau){
corps
}
1.4
for( int i = 0 ; i
variable de type = tableau[i]
corps
}
Listes de tableaux génériques
5.0
ArrayList arrayList = new ArrayList();
arrayList.get(i);
1.4
ArrayList arrayList = new ArrayList();
type arrayList.get(i);
AutoBoxing
5.0
Integer entier = n;
int n = entier;
1.4
Integer entier = new Integer(n);
int n = entier.intValue();
Listes de paramètres Variables
5.0
maMethode(autres paramètres,p1,p2,p3 );
1.4
maMethode(autres paramètres, new Type[]{p1,p2,p3});
pour déclarer la fonction on utilise la syntaxe suivante par exemple :
String max(String nomTableau,double... valeurs) {
double leMax = Double.MIN_VALUE;
for (double v : valeurs) {
if (v > leMax) {
leMax = v;
}
}
return "le max des" +nomTableau+" est : "+leMax;
}
max("Notes",5, 2, 54, 12, 35,62);
Type de retour covariants :
5.0
public Personne clone(){...}
...
Personne cloner = e.clone();
1.4
public Object clone(){...}
...
Personne cloner = (Personne) e.clone();
Importation static
5.0
import static java.lang.Math;
import static java.lang.System;
out.println(cos(45));
1.4
System.out.println(Math.cos(45));
Saisie à la console
Scanner in = new Scanner(System.in);
int entier = in.nextInt();
double nombre = in.nextDouble();
String chaine = in.nextLine();
Aucun commentaire:
Enregistrer un commentaire