Boolean.parseboolean ("true") and Boolean.getboolean ("true"), the difference and usage

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.