print it's
WAP to input a 4 4 digit number and
reverse in java
Answers
Answered by
0
I have used the reverse() function
import java.util.Scanner;
public class NumberReverser {
int reverse = 0;
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
StringBuilder number = new StringBuilder(sc.next());
System.out.print("The reversed number is ");
System.out.print(number.reverse());
}
}
Output:
Enter a number: 123456789
The reversed number is 987654321
Similar questions