Knowledge Walls
John Peter
Pune, Maharashtra, India
Boolean.valueOf() casting problem in Core Java with Example
1379 Views
Boolean.valueOf() 
Boolean.valueOf() is accepting only true or false in all case. But not accepting 1 as true and 0 as false.
Example
public class Example {
    public static void main(String args[]) throws Exception{    
        System.out.println(Boolean.valueOf("true"));
        System.out.println(Boolean.valueOf("True"));
        System.out.println(Boolean.valueOf("TRUE"));
        System.out.println(Boolean.valueOf("1"));
        
        System.out.println(Boolean.valueOf("false"));
        System.out.println(Boolean.valueOf("False"));
        System.out.println(Boolean.valueOf("FALSE"));
        System.out.println(Boolean.valueOf("0"));
    }
}
Output 
true
true
true
false

false
false
false
false
Best Lessons of "One day One Thing to Know"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details