• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

toXxxString() explain me logic

 
Ami Ambre
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
You will probably need to rethink your post
and clarify exactly what you do not understand...
Regards
 
Mamta Sharma
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic