wohhie
2/6/2017 - 8:11 AM

Reversing a int example : int a = 12345 , so it will show as 54321 in display

Reversing a int example : int a = 12345 , so it will show as 54321 in display

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception	{
		
		int a = 12345;
		int r = 0, reverse = 0;
		int left = a;
		 
		while( left > 0) {
			r = left % 10;
			reverse = reverse * 10 + r;
			left = left / 10;
		}
		
		System.out.print(reverse);
		
		
		
	}
}