Hi,
What is the difference between compile time and run time actually... If a value of a variable is already known before it runs...then it is compile time..so when u say
byte b= 1;//this is ok...coz value of b is 1 which is a constant so you dont have to say byte b=(byte)1...that is at compile time the value of b is already decided before it runs..right.
now let is c the following statement...
b=b+1;
the value of b can vary...coz it is not a final variable..and taking this statement individually...when u say b= b+1..the value of b can vary it cud be anything...so it is not a constant meaning the value of b is deduced at run time..so it throws an error at compile time..
ok lets for a moment assume that complier implitcitly casts this...so there is gonna b loss or precision right? complier wud do it even if u dont know actually what happened..but when u say b=(byte)(b+1); u r actually saying to the compiler hey...I know what am doing..even though the value is changed am aware of it. Actually this makes the program lot easier.
Cecilia
