Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to reverse numbers in java

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num = input.nextInt();

        int rev = 0;

        while (num > 0) {
            rev = rev * 10 + num % 10;
            num /= 10;
        }
        System.out.println(rev);
    }
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #reverse #numbers #java
ADD COMMENT
Topic
Name
3+6 =