• 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

Boolean class (Wrapper)

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}}
 
Author
Posts: 3473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ).
reply
    Bookmark Topic Watch Topic
  • New Topic