theme: Plain Jane autoscale: true
- int + long == long
- int+ float == float
- byte, short, char --> promote to int always
byte b1 = 1;
byte b2 = 1 + b1; // error
---
byte b1 = 1;
byte b2 = (byte)(1 + b1);byte b3 = b1++; // OK
b1 = b1 += 1; // OK
b1 = b1 + 1; // error
System.out.println(b1 + 1); // OK ¯\_(ツ)_/¯= no es ==
int i = 10;
long l = 10;
double d = 10.9;
float f = 10.0;- +, -, ++, --
- postfix & prefix ++
- |, &, !: int / boolean
- ||, &&: short-circuit operators
- curly braces not mandatory
int x = 0;
if (x == 10) {
x = 11;
} else {
x == 10;
}
// value of x?int x = 0;
if (x == 10)
x = 11;
x--;
else
x = 10;int x = 0;
switch (x) {
case 10:
case 7:
case 4:
break;
default:
}String name = "spongebob";
switch (name) {
case "spongebob":
case "7":
case "PatrickStar":
break;
default:
}el resto: a leer