1.
final int y = 9;
int i = y++;
not compile, cannot change y value.
------------------------------------------------------------------------------------------------------------
2.
float i = 3;
byte b =3;
b+=i;
compile, += performs autocast
float i = 3;
byte b = 3;
b = b+i;
will not compile
------------------------------------------------------------------------------------------------------------
3.
int [] tab = new int['a'];
will compile, chars are implicitly promoted to ints
------------------------------------------------------------------------------------------------------------
4.
private int get() {
return Integer.MAX_VALUE+1; //correct, also for long, float and double
}
private short get() {
return Short.MAX_VALUE+1; //incorrect
}
private byte get() {
return Byte.MAX_VALUE+1; //incorrect
}
Brak komentarzy:
Prześlij komentarz