How to Create a Program to Print Reverse of a Number in Core Java

In this tutorial how to create a program to print reverse of a number in Core Java  is shown.

Code:

ReverseNo.java

class ReverseNo
{
public static void main(String args[])
{
int number=Integer.parseInt(args[0]),sum=0,r,copyn;
copyn=number;
while(copyn>0)
{
r=copyn%10;
sum=(sum*10)+r;
copyn/=10;
}
System.out.println(“The reverse of “+number+” is “+sum);
}
}

https://youtu.be/B_oNaY03PyQ

Add a Comment

Your email address will not be published. Required fields are marked *