Datatypes
int |
2, 5, -3, -10, 22 |
float |
2.5, 3.2, 10.15, -2010, 0, 0.01 |
String |
"Nom", "Client", "ModDePasse", "-5.2" |
boolean |
true, false |
Declarations
DATATYPE VARIABLE; |
DATATYPE VARIABLE = VALEUR; |
DATATYPE VARIABLE, VARIABLE2; |
DATATYPE VARIABLE = VALEUR, VARIABLE2 = VALEUR2; |
Conditional
if |
if(CONDITION) {} |
if else |
if(CONDITION) {} else {} |
if else if |
if(CONDITION) {} else if(CONDITION2) {} |
|
|
Printing
System.out.println("Message"); |
System.out.println(Variable); |
Scanning
import java.util.Scanner; |
Scanner NOM = new Scanner(System.in); |
int variable = scanner.nextInt(); |
float variable = scanner.nextFloat(); |
String variable = scanner.nextLine(); |
Boucle
while |
while(CONDITION) { } |
for |
for(int i = 0; i < max; i++) { } |
do while |
do {} while(CONDITION); |
|
|
Arrays (Tableau)
TYPE nom[]; |
nom = new TYPE[TAILLE]; |
TYPE nom[] = new TYPE[TAILLE]; |
TYPE nom = { valeur1, valeur2, valeur3 }; |
Array Loop
int tableau[] = new int[5];
for(int i = 0; i < 5; i++){
tableau[i] = valeur;
// possible:
tableau[i] = scanner.nextInt();
}
|
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets