Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javatechie.interview.programming;
- public class ReverseNumber {
- public static int reverse(int no) {
- int temp = 0;
- while (no != 0) {
- temp = temp * 10 + no % 10;
- no = no / 10;
- }
- return temp;
- }
- public static void main(String[] args) {
- System.out.println(reverse(123));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement