Tuesday, February 26, 2008

-C-O-N-C-E-P-T- Series : Java

<CONCEPT>

Casting String to Boolean in Java:

We can achieve this using the Boolean class' static method:
Boolean.parseBoolean(String s) - returns a boolean value

Sample code:


String str = "true";
if( Boolean.parseBoolean(str) ){
    System.out.println("Value is true");
} else{
    System.out.println("Value is false");
}


Casting Boolean to String in Java:

We can achieve this using the String class' static method:
String.valueOf(boolean b) - returns the string representation of the boolean argument

Sample code:


boolean blnFlag = true;
String strVal = String.valueOf(blnFlag);

</CONCEPT>

2 comments:

Anonymous said...

lol,so nice

Anonymous said...

Good article, good things, good feelings, good BLOG!


_________________________________________________________________________________________________________________

"Look at the sky. We are not alone. The whole Universe is friendly to us and conspires only to give the best to those who dream and work."

- Dr. A P J Abdul Kalam
_________________________________________________________________________________________________________________