Q:

NumberFormatException error on returning largest number?

I'm practicing Java online and one of the practice problems is to:
"Write a method called largerAbsVal that takes two integers as parameters and returns the larger of the two absolute values. A call of largerAbsVal(11, 2) would return 11, and a call of largerAbsVal(4, -5) would return 5."
I have already wrote my method solution which so far is:
public static int largerAbsVal(int a, int b) {
    return Math.max(Math.abs(a), Math.abs(b));
}

But for some reason, the website keeps telling me that my code caused an error of type NumberFormatException? I already declared the two parameters as integers at the heading so what exactly is wrong with my code in this case?
Any help is greatly appreciated! 

A:

From NumberFormatExecpton:

Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format.

The code you posted works great!  My guess is your error is somewhere before that piece of code where you're converting a string to an int. Example:
Integer.parseInt(string)

And that the string given is malformed (i.e. not an int).  For example, something like "2.1" will throw an error like this.
Hope this helps!

