Nov 10, 2018

How to reverse a number in Java for interview

public int reverse(int number) { int reverse = 0; while (number != 0) { reverse = reverse * 10 + number % 10; number = number / 10; } return reverse; }