Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Harry Potter's Miracle in Boolean

 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • 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
 
Matthew Brown
Bartender
Posts: 4566
8
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Henry Wong
author
Marshal
Pie
Posts: 20997
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got confuse becaude even K&B showing no parseXxx method for Boolean and Character class.

 
Henry Wong
author
Marshal
Pie
Posts: 20997
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saloni jhanwar wrote:



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

Henry
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you feel it's an mistake in the book, you can log an entry here - http://www.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".
 
Mike Simmons
Ranch Hand
Posts: 3038
10
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I agree to that, Mike.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic