How to convert String object to Boolean Object?

前端 未结 14 839
我寻月下人不归
我寻月下人不归 2020-11-28 01:28

How to convert String object to Boolean object?

14条回答
  •  忘掉有多难
    2020-11-28 02:03

    you can directly set boolean value equivalent to any string by System class and access it anywhere..

    System.setProperty("n","false");
    System.setProperty("y","true");
    
    System.setProperty("yes","true");     
    System.setProperty("no","false");
    
    System.out.println(Boolean.getBoolean("n"));   //false
    System.out.println(Boolean.getBoolean("y"));   //true   
     System.out.println(Boolean.getBoolean("no"));  //false
    System.out.println(Boolean.getBoolean("yes"));  //true
    

提交回复
热议问题