• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic