This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

toHexString(int i) unnecessary ?

 
Timothy Toe
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why wrapper class Integer has 2 methods to convert a base 10 int to a Hex (base 16) string ?
static String toString(int i, int radix)
static String toHexString(int i)
eg: to convert 15 to F
Integer.toHexString(15) returns f
Integer.toString(15, 16) also returns f

If we already have the generic method
static String toString(int i, int radix)
why do we still need
static String toHexString(int i) ?
Doesn’t the former makes the latter unnecessary ?
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For conveniance, in case you do not want to have to specify the default radix each time you use the method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic