• 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

Harry Potter's Miracle in Boolean

 
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whereas I know there are only six parseXxx() methods for numeric type of primitives.
There is no method for Boolean class then how thiscode is working and printing even true

Output:true
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What makes you think the method doesn't exist? It's there in the documentation.
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matthew Brown wrote:What makes you think the method doesn't exist? It's there in the documentation.


http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Boolean.html
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

saloni jhanwar wrote:

Matthew Brown wrote:What makes you think the method doesn't exist? It's there in the documentation.


http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Boolean.html




The parseBoolean() method was added with Java 5.... perhaps you should use a version of the JavaDoc that matches the version of Java that you are using.

Henry
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got confuse becaude even K&B showing no parseXxx method for Boolean and Character class.

 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

saloni jhanwar wrote:




JavaRanch automatically links to the latest JavaDoc -- for example.... java.lang.Boolean.

Henry
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How old is your book? Have a look through all those classes for valueOf methods, and I think you will find more than there are in your table.
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:How old is your book? Have a look through all those classes for valueOf methods, and I think you will find more than there are in your table.



My book is new, i have K&B 6,and that snap was from k&b 6.
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you feel it's an mistake in the book, you can log an entry here - https://coderanch.com/t/467890/java-programmer-SCJP/certification/Compiling-errata-SCJP

But it looks okay to me as the authors have clearly mentioned in the picture title - "Common Wrapper Conversion Methods" and not "All".
 
Master Rancher
Posts: 4830
74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Jai wrote:But it looks okay to me as the authors have clearly mentioned in the picture title - "Common Wrapper Conversion Methods" and not "All".


Hmmm, I don't buy that. It would be fine if they simply didn't mention parseXxx at all - then your argument would apply. But they do have a row for the parseXxx methods - and on that row, an X is supposed to indicate the method exists, and a lack of an X indicates it does not. The table was correct for an earlier version of Java, but it looks like that new parse method was overlooked for the last two editions of the book. At least one valueOf() method was overlooked as well. Maybe more.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree to that, Mike.
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agree with Mike S; the parseBoolean() method has been around for nearly eight years, and even I have used it
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic