This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile 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