Wednesday, 28 August 2013

Is addition of byte converts to int is because of java language rules or because of jvm?

Is addition of byte converts to int is because of java language rules or
because of jvm?

byte a = 1;
byte b = 1;
byte c = a + b;
Throws error: possible loss of precision
byte subt = a_s - a_b;
^
required: byte
found: int
Is this behavior has something to do with jvm or its been defined in java
language .
EDIT : And if it is defined in java language then does it because of
keeping jvm in mind ?
Means if java supports byte datatype then why operation on byte results int

No comments:

Post a Comment