do we need to explicitly cast as you have done aboveJava will cast primative types for you, provided that it does not involve a loss of precision. Since a long can hold all the values an int can, the cast will be performed automatically, but you would have to explicitly cast (for example) a long if you wanted to use it where an int should be.
or will it be implicitly handled by java
Message was edited by:
x = (int)x;
@vik: be carefull when doing the thing ggopi suggested, when b exceeds 2147483647 (== (2^31)-1 == Integer.MAX_VALUE), you will get a NumberFormatException.Thanks I will test now. Also can you please tellmehow I convert a Long to an Integer?int a ;
long b = 1;