File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boolean class (Wrapper)

 
priya rishi
Ranch Hand
Posts: 119
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code is working,
but we dont have parseBoolean() in Boolean wrapper class.
Then how?

code is as follows:
class booleanDemo{
public static void main(String args[])
{
boolean bl2 = Boolean.parseBoolean("true");
System.out.println(bl2);
}}
 
arulk pillai
Author
Ranch Hand
Posts: 3380
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the package name in the import statements. Sorry, it exists in Java 5 (i.e. is 1.5.0 onwards).


http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Boolean.html
[ October 26, 2008: Message edited by: arulk pillai ]
 
Rob Spoor
Sheriff
Pie
Posts: 20381
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Java 1.4 and earlier you can simply use Boolean.valueOf("true").booleanValue().

The trick is that Boolean.valueOf returns Boolean.TRUE or Boolean.FALSE. Not just object equal to those, but those very same objects themselves (well, references to them of course). So valueOf will not create a new Boolean object each time you use it, and therefore will be just one method call less efficient. In milliseconds, the difference will be 0, and you won't even notice it (unless perhaps you have billions of these calls ).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic