Carinha, olha sempre a referência da API: ó, to colando da API reference.
valueOf
public static Integer valueOf(String s)
throws NumberFormatException
Returns an Integer object holding the value of the specified String. The argument is interpreted as representing a signed decimal integer, exactly as if the argument were given to the parseInt(java.lang.String) method. The result is an Integer object that represents the integer value specified by the string.
In other words, this method returns an Integer object equal to the value of:
new Integer(Integer.parseInt(s))
Parameters:
s - the string to be parsed.
Returns:
an Integer object holding the value represented by the string argument.
Throws:
NumberFormatException - if the string cannot be parsed as an integer.
Se você quiser converter números hexadecimais, você tem que usar outro método:
valueOf
public static Integer valueOf(String s,
int radix)
throws NumberFormatException
Returns an Integer object holding the value extracted from the specified String when parsed with the radix given by the second argument. The first argument is interpreted as representing a signed integer in the radix specified by the second argument, exactly as if the arguments were given to the parseInt(java.lang.String, int) method. The result is an Integer object that represents the integer value specified by the string.
Agora, tem um porém na história: ele não aceita o “x” que você está colocando na String. Ele só aceita dígitos (ou letras se a base for maior que 10) . De novo, carinha, olhe a API.