Xris Xris - 5 months ago 24
Java Question

What is "Integer.valueOf().intValue()" supposed to do?

Here is a java line of code that i have failed to understand.

String line = "Some data";//I understand this line
int size;//I understand this line too

size = Integer.valueOf(line,16).intValue();//Don't understand this one


What i know is Integer.ValueOf(line) is the same as Integer.parseInt(line) , is not so? Correct me if i am wrong; Thanks.

Answer

Integer.ValueOf(line,16) converts string value line into an Integer object. In this case radix is 16.

intValue() gets the int value from the Integer object created above.

Furthermore, above two steps are equivalent to Integer.parseInt(line,16).

In order to get more INFO please refer Java API Documentation of Integer class.

Comments