Write java program to reverse of given number

import java.util.Scanner;
class Reverse 
{
int no;
        //To initialize values
Reverse(int n)
{
no=n;
}
        //To reverse number
void rev()
{
int s=0,r=0;
while(no>0)
{
r=no % 10;
s=s*10+r; 
no=no/10;
}
System.out.println(" Reverse is :- "+s);
}
}
//To create object 
class TestReverse
{
public static void main(String args[])
{
int n;
Scanner a=new Scanner(System.in);
System.out.println("\nEnter number :- ");
n=a.nextInt();
Reverse obj=new Reverse(n);
obj.rev();
}
}

1 Comments

  1. we'd reallly appreciate if you also upload hello world programe of all the languages. Especially java.

    ReplyDelete