I was is happy with my concept that arithmetic operations are performed at runtime and compiler doesn't bother about it until i see the output of following code:
public class TestFinalVariables {
public static void main(
String []argv)
{
final int firstInt=12, secondInt=5;
byte b=firstInt+secondInt;
System.out.println("7 + 5: "+b);
}
}
compiler doesn't complain anything wrong in the code and output is
"7 + 5= 12"
but compiler starts complaining that int can't be converted to byte when i make following changes:
final int firstInt=125, secondInt=5;
it means that arithmatic operations are performed at compile time ???
confused