I want to reverse an inputted number. I've written the code for it. But i need to know if it could have been done in any other much faster way. Please feel free to modify my code.
public static void main()throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
int num=Integer.parseInt(in.readLine());
int no=num;
int d;
int rev_no=0;
int digits=0;
while(num>0)
{
num/=10;
digits++;
}
while(no>0)
{
d=no%10;
rev_no+=d*(Math.pow(10,(digits-1)));
no/=10;
digits--;
}
System.out.println(rev_no);
}