File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes toXxxString() explain me logic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "toXxxString() explain me logic" Watch "toXxxString() explain me logic" New topic
Author

toXxxString() explain me logic

Ami Ambre
Ranch Hand

Joined: Dec 26, 2007
Posts: 58
I have not understand properly with this link
http://en.wikipedia.org/wiki/Hexadecimal
please explain me logic

Integer & Long wrapper classes convert numbers in base 10 to other bases.
Conversion methods, toXxxString() take an int or long & return a
String representation of the Converted number, for e.g
String s1=Integer.toHexString(254);//convert 254 to hex

System.out.println("254 is" + s1);//"254 is fe"

String s2=Integer.toOctalString(254);//convert 254 to octal

System.out.println("254 (oct) =" + s1);//"254 (oct)=376"
Keith Nagle
Ranch Hand

Joined: May 06, 2008
Posts: 65
Hello.
You will probably need to rethink your post
and clarify exactly what you do not understand...
Regards


SCJP 5.0
Mamta Sharma
Greenhorn

Joined: Jun 03, 2008
Posts: 25
Hi there,
you have provided the code:-
String s1=Integer.toHexString(254);//convert 254 to hex

System.out.println("254 is" + s1);//"254 is fe"

String s2=Integer.toOctalString(254);//convert 254 to octal

System.out.println("254 (oct) =" + s2);//"254 (oct)=376"
Everything is fine with this code, 254 is fe(1514)in hexadecimal & 376 in octal representation.
Do you still have any doubt??
[ July 09, 2008: Message edited by: Mamta Sharma ]
[ July 09, 2008: Message edited by: Mamta Sharma ]
 
Don't get me started about those stupid light bulbs.
 
subject: toXxxString() explain me logic