Les gens oublient. Surtout si vous écrivez dans différentes langues. Si vous le lisez avant d'écrire, vous pouvez faire beaucoup de progrès.
| Moule | La description | intervalle | 
|---|---|---|
| byte | Entier 8 bits | -128~127 | 
| short | Entier 16 bits | -32,768~32,767 | 
| int | Entier 32 bits | -2,147,483,648~2,147,483,647 | 
| long | Entier 64 bits | -9,223,372,036,854,775,808~9,223,372,036,854,775,807 | 
| char | Caractère Unicode 16 bits | \u0000~\uFFFF | 
| float | Virgule flottante 32 bits | (réduction) | 
| double | 64 bits à virgule flottante | (réduction) | 
| boolean | - | true, false | 
5 + 2;		//7 ajout
5 - 2;		//3 soustraction
5 * 2;		//10 multiplication
5 / 2;		//2 division
5 % 2;		//1 surplus
y = ++x;	//Préfixe y= (x += 1);
y = x++;	//Postfix y= x; x = x + 1;
x < y;		//Moins que
x <= y;		//Moins que
x >= y;		//c'est tout
x > y;		//Excès
x == y;		//Équivalent
x != y;		//Inégal
x && y;		// AND
x || y;		// OR
!x;			// NOT
String str = "Chaîne";			//Initialisation
str.length();					//longueur
str.subString(start, end);		//commencer à finir-Découper 1
str1.equals(str2);				//Jugement équivalent
str1.compareTo(str2);			  //Comparaison
// str1 < str2 -> -1
// str1 == str2 -> 0
// str1 > str2 -> 1
char c = str.charAt(i);				// String ->char i e caractère
char[] cs = str.toCharArray();		// String ->char entier
int i = Integer.parseInt(str);		// int <- String
int i = (int) d;					  // int <- double
double d = Double.parseDouble(str);	// double <- String
double d = (double) i;				  // double <- int
String s = String.valueOf(i);			// String <- int
String s = String.valueOf(d);			// String <- double
Math.max(2, 5);		//5 plus grand
Math.min(2, 5);		//2 plus petits
Math.abs(-3);		//3 valeur absolue
Math.ceil(1.5);		// 2.0 arrondi
Math.floor(1.5);	// 1.0 troncature
Math.round(1.5);	// 2.0 arrondi
Math.pow(2, 10);	//1024 puissance
Math.sqrt(2);		// 1.414 ... racine carrée
Math.log10(1000);	//3 Logarithmique commune
Math.PI				//rapport de circonférence π
Math.E				//e Le bas du logarithme naturel
Je vais peut-être l'écrire bientôt.
if
if ( i > 0 ) {
  ;
} else if ( i < 0 ) {
  ;
} else {
  ;
}
for / for-each
for ( int i = 0; i < max; i++ ) {
  ;
}
for ( var : collection ) {
  ;
}
while / do-while
while ( i > 0 ) {
  ;
}
do {
  ;
} while ( i > 0 );
switch
switch ( i ) {
  case 0:
    ;
    break;
  case 1:
    ;
    break;
  default:
    ;
}
//Initialisation
int[] num = new int[10];
Arrays.fill(num, 0);
//Copie profonde copie profonde
String[] copySrc = new String[10];	//Original
String[] copyDst = new String[10];	//Copier
copyDst = Arrays.copyOf(copySrc, copySrc.length);
//Initialisation
int[][] num = new int[10][10];
for (int i = 0; i < num.length; i++) {
	Arrays.fill(num[i], 0);
}
//Copie profonde
String[][] copySrc = new String[10][10];	//Original
String[][] copyDst = new String[10][10];	//Copier
for (int i = 0; i < copySrc.length; i++) {
	copyDst[i] = Arrays.copyOf(copySrc[i], copySrc[i].length);
}
//Initialisation
List<String> list = new ArrayList<String>();
//Manipulation par objet
list.add(str);		//ajouter à
list.remove(str);	//Effacer
list.indexOf(str);	//Obtenir l'index
list.contains(str);	//Contrôle d'existence
//Fonctionnement par index
list.get(i);		//Obtenez i th
list.set(i, str);	//Remplacez-moi
//Initialisation
// key -> int
// value -> String
HashMap<Integer, String> hMap = new HashMap<Integer, String>();
hMap.put(i, str);		//ajouter à
hMap.get(i);			//Avoir
hMap.containsKey(i);	//Contrôle d'existence
PriorityQueue<Integer> pQueue = new PriorityQueue<Integer>();
pQueue.offer(i);	//ajouter à
pQueue.peek(i);		//Obtenir (ne pas supprimer de la file d'attente)
pQueue.poll(i);		//Get (supprimer de la file d'attente)
        Recommended Posts