Here is the example.
public class reverseNum { public static void main(String[] args) { int number=1011; int reverseNumber = reverse(number); System.out.println(reverseNumber); } private static int reverse(int number){ int reverse = 0; int sum=0; while(number != 0){ reverse = reverse*10 + number%10; number = number/10; } return reverse; } }
No comments:
Post a Comment