Correct usage: Boolean repeatindicator = Boolean.valueof ("true"). Booleanvalue ();
Or you can use the Boolean.parseboolean () method, but this method is jdk1.5 later.
The following are the correct uses of Boolean.getboolean:
public class Testgetboolean
{
public static void Main (string[] args) {
True of uppercase returns to false, must be lowercase
String S1 = "true";
String s2 = new String ("true");
This will store the S1 in the Java System Properties.
System.setproperty (S1, "true");
System.setproperty (S2, "true");
This gets the S1 from the system properties.
System.out.println (Boolean.getboolean (S1));//true
System.out.println (Boolean.getboolean (S2));//true
String s3 = "true";
It is clear that the S3 is not stored in the system properties and therefore returns false.
System.out.println (Boolean.getboolean (S3));//false
This is more wrong, hehe.
System.out.println (Boolean.getboolean ("true"));//false
}
}
Boolean.parseboolean ("true") and Boolean.getboolean ("true"), the difference and usage