Question: Write a static method public static int reverse(int n) which will, given an integer n (which may be negative), return a number that reverse
Write a static method public static int reverse(int n) which will, given an integer n (which may be negative), return a number that reverse the digits of the integer n. Your function should ensure that both non-negative and negative numbers are correctly handled. For example: If n equals 8645, the function will return an int 5468 If n equals -8645, the function will return an int -5468.
Step by Step Solution
There are 3 Steps involved in it
This program defines a reverse method that takes an integer n and returns its reverse considering bo... View full answer
Get step-by-step solutions from verified subject matter experts
