java - Converting Byte To Int,Short To Long...etc -



java - Converting Byte To Int,Short To Long...etc -

i'm learning java , don't know much it. formula of converting bigger info types smaller ones?for example:

byte x=10; long y=250; x=(byte)y; system.out.println(x);

after compiling gives me -6. , uses have?

you getting -6 because made long byte , value in long big byte. seek convert byte long!

a byte has range -128 127. long goes -2^63 2^63-1. have gotten overflow becuase of converting in way.

java

Comments