This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

toHexString(int i) unnecessary ?

 
Timothy Toe
Ranch Hand
Posts: 156
  • 0
  • 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
  • 0
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic