toXxxString() (Binary, Hexadecimal, Octal)

toXxxString() (Binary, Hexadecimal, Octal)

The Integer and Long wrapper classes let we convert numbers in base 10 to other bases. These conversion methods, toXxxString(), take an int or long, and return a String representation of the converted number, for example : 
String s3 = Integer.toHexString(254); // convert 254 to hex
System.out.println(\"254 in hex = \" + s3); // result is \"254 in hex = fe\"
String s4 = Long.toOctalString(254); // convert 254 to octal
System.out.println(\"254 in octal = \"+ s4); // result is \"254 in octal = 376\"

Date:2013-03-09 00:00:00

Post Your Answers

User Email:

User Name:

Related scjp1.5 chap7 Links

scjp1.5 chap7 interview questions and answers for experienced and fresher