基本类型
结构
关键词
- void
- boolean(1-bit)
- char (16-bit, Unicode)
- byte (8-bit)
- short (16-bit)
- int (32-bit)
- long (64-bit)
- float (32-bit)
- double (64-bit)
操作符
- arithmétiques: + - * / %
- relationnels: == (égalité) <= >= < > !=
- logiques: ! (non) && (et) || (ou)
- incréments: ++ --
- opérateurs sur les bits: & | ^ ~ >> << >>>
- affectation: = -= += *= /=
- conditionnel: ? et \
variable = condition ? valeur_si_vrai : valeur_si_faux
^ = xor, ~ = no
>> conserve du signe, >>> seulement complete avec 0
if else
for(;;) or for( :)
while()条件为真进入循环
do{}while();
switch(variable){case : break; default: break}
表
- Déclaration
int[] array_of_int; // équivalent à : int array_of_int[];
int rgb[][][];
- Création/Initialisation
array_of_int = new int[42];
array_of_int[0] = 3;
rgb = new int[256][256][256];
int[] primes = {1, 2, 3, 5, 7, 7 + 4};
- Utilisation
int length = array_of_int.length;//length == 42
int integer = array_of_int[0];//integer == 3
对象复制实际是对pointer的复制
基本类型的复制是对数值的复制
声明和初始化
声明可以是父类,interface或是本身,这是表面的属性
初始化决定了对象的真实属性
在被外界使用时被看做为表面属性,执行动作时动用真实属性
encapsulation:
private, public, protected
Mot-clef | Classe | Package | Sous-Classe | Tous |
---|---|---|---|---|
public | O | O | O | O |
protected | O | O | O | N |
aucun | O | O | N | N |
private | O | N | N | N |