Here is a line of java code that I did not 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
I know that Integer.ValueOf (string ) is the same as Integer.parseInt (string) , right? Correct me if I am wrong; Thank.
Integer.ValueOf(line,16)converts a string value lineto an object Integer. In this case, the radius is 16.
Integer.ValueOf(line,16)
line
Integer
intValue()gets the value intfrom the one created above Integer object.
intValue()
int
object
In addition, the above two steps are equivalent Integer.parseInt(line,16).
Integer.parseInt(line,16)
For more information, see the Java Integer API documentation .
, :
size = Integer.parseInt(line, 16);
, , :
size = Integer.valueOf(Integer.parseInt(line, 16)).intValue();
.
-1 , , . , , Integer.parseInt, size , Integer.valueof, .
Integer.parseInt
size
Integer.valueof
public class Test { public static void main(String[] args) { String s = "CAFE"; Integer m = Integer.valueOf(s, 16); int n = m.intValue(); System.out.println(n); } }
Integer - , int, .
" = Integer.valueOf().intValue()"
:
String myNumber = "54"; int c = Integer.valueOf(myNumber).intValue(); // convert strings to numbers
54 // like int (and before was a String)