This is my Example java
code.
class Example{
public static void main(String args[]){
int x = 65;
final int y = 65;
final int z;
z = 65;
char ch;
ch = 'A';
ch = 65;
ch =(char) x; // narrow casting
ch = y; //line 2
ch = z; //line 3 compile time error
}
}
why when final variable y
initialize value inline that variable compatible to smaller data type without casting
but final variable z
initialize value after declared it that occurs compiler error.
Please tell me technically why this happens.