• 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

Wrapper conversion methods..

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess the thing you are about to read will be bugging for those who reply.
please refer to kathy book pg:233, they have given a table mentioned WRAPPER CONVERSION METHODS and there are lot of stuff in it. i really could not interpret the table. can anyone explain me how to read that table.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The wrapper classes are listed across the top of the table. Each column shows whether that wrapper has the methods listed down the left side of the table. The parseXxx methods refer to the static methods which convert a String to a the primitive type associated with that wrapper. The Xxx is the primitive type that is returned (only capitalized to fit the Java naming conventions). If you are looking at the Float column, the method would be parseFloat(); If you are looking at the Integer column, the method would be parseInt(). If the wrapper has that method, there will be an "X" in the appropriate row for that column. So if you look at the row for the method doubleValue(), you will see that the Boolean wrapper class does not have that method, but the Byte wrapper class does.

[As an aside, the Java 6 version of K&B is out and has sufficient revisions to make the page numbers different. It would be helpful to note which edition of the book you are referencing.]
 
venkatesh badrinathan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Mr.Jamie i have understood a portion of the table.. but how about parseXxx
(with radix), i do not know what is radix, also they have given as 'n' over there. do they imply that the method throws numberformatexception???(pg:233 in kathy 1.5 book ).also please let me know whether we have to memorise all the stuff given in that table??
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I understand that Radix refers to the base(octal, Hex...):

Example:
System.out.println(Integer.parseInt("100", 16));
----
parseXxx( "String number", Radix)

Checking: http://mindprod.com/jgloss/radix.html

Now 'n', I believe that NumberFormatException
parseXXX(String) throws NumberFormatException

See ya
 
venkatesh badrinathan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Theank you mario
 
Jamie MacDonald
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yay Mario--first post!

If you look at the section entitled parseXxx() and valueOf() 2 pages before the table it shows some more examples of using parseXxx with a radix and also mentions throwing a NumberFormatException if the String argument is not properly formed. The String is not a properly formed number if it contains any character that does not comprise a number of the specified radix (or a decimal--base 10--number is no radix is specified). So a string containing the letter "z" would always cause the exception, and a string with a "3" would cause the exception if the radix were 2 since binary numbers contain only "0" and "1".
 
Mario Razec
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
My first post, now my second post =)
I was read javaranch but never post.
Interesting explanation Jamie...
Thanks a lot..

see ya
 
bacon. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic