25 April 2013

How to convert from Long to Integer object in Java ?

How to convert from Long to Integer object in Java ?

You need convert from Integer to Number and then convert from Number to Long using .longValue
Steps: Integer->Number->Long
See this silly method to find your solution ;).
(Silly as is done step by step without shortcuts)

public Long convertFromIntToLong(Integer num){
Integer numAsInteger = num;
Number numAsNumber = numAsInteger ;
Long numAsLong = numAsNumber.longValue();
return numAsLong;
}


I hope,it helps.

No comments:

Post a Comment