This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Franz Fountain
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
valueOf(String, radix)
valueOf(int)

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
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Franz,
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic