Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in K&B SCJP 5: topic 3 valueOf's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in K&B SCJP 5: topic 3 valueOf Watch "Doubt in K&B SCJP 5: topic 3 valueOf New topic

Doubt in K&B SCJP 5: topic 3 valueOf's

Franz Fountain
Ranch Hand

Joined: Nov 15, 2006
Posts: 58
On p. 233 Table 3-3

There are 2 valueOf methods listed. There are actually 3 valueOf methods.

For example the Integer class has the following:
valueOf(String, radix)

I think of this table as showing conversion methods from 1 type to another. Some example
Integer.valueOf(String) - converts from String to Integer
Integer.valueOf(int) - converts from int to Integer

Curiously enough there is another way to make the same conversions as above - that's with constructors.
Integer i1 = new Integer(String) - converts from string to Integer
Integer i2 = new Integer(int) - converts from int to Integer
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
Yes there are actually 3 methods and K&B has mentioned only 2 which are important.By default the radix is 10 for all the valueOf(String string) method unless you specify them.
What is the confusion?

~Sanjeev Singh<br />SCJP 1.5
I agree. Here's the link:
subject: Doubt in K&B SCJP 5: topic 3 valueOf's