This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes toHexString(int i) unnecessary ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "toHexString(int i) unnecessary ?" Watch "toHexString(int i) unnecessary ?" New topic

toHexString(int i) unnecessary ?

Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
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

Joined: Jul 03, 2001
Posts: 2120
For conveniance, in case you do not want to have to specify the default radix each time you use the method.

SCJP2. Please Indent your code using UBB Code
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: toHexString(int i) unnecessary ?
It's not a secret anymore!