What is wrong with the following java boolean codes?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpuser123
    New Member
    • Dec 2009
    • 108

    What is wrong with the following java boolean codes?

    I want to parse a string into a boolean value and I implemented this script ..

    public static void test_lang_boole an(){


    System.out.prin tln("boolean false from string "+Boolean.parse Boolean("Boolea n.FALSE"));
    System.out.prin tln("boolean true from string "+Boolean.parse Boolean("Boolea n.TRUE"));
    }


    When I run this code,I get false for both..
    I expected to get false for the first one and true for the second ..
    Any1 can show me what's wrong here...

    Thanks in adv
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    Try

    Code:
    public static void test_lang_boolean(){
    
    
    System.out.println("boolean false from string "+Boolean.parseBoolean("FALSE"));
    System.out.println("boolean true from string "+Boolean.parseBoolean("TRUE"));
    }

    Comment

    Working...