-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:
lol,so nice
Good article, good things, good feelings, good BLOG!
Post a Comment