programming-examples/java/_Basics/Program to ReverseNumber (Java) v2.java

20 lines
460 B
Java
Raw Normal View History

2019-11-15 12:59:38 +01:00
public class NumberReverse
{
public int reverseNumber(int number)
{
int reverse = 0;
while(number != 0)
{
reverse = (reverse*10)+(number%10);
number = number/10;
}
return reverse;
}
public static void main(String a[])
{
NumberReverse nr = new NumberReverse();
System.out.println("Result: "+nr.reverseNumber(17868));
}
}