Differences between Boolean and Boolean types of data

Source: Internet
Author: User
Working on a page-passing Boolean type of data problem that needs to be judged in code that cannot be null, think about the difference between a Boolean and a Boolean?
Boolean is the basic data type
The Boolean is its wrapper class, like any other class, has attributes that have methods that can be new, for example:
Boolean flag = New Boolean ("true"); A Boolean is not possible!
Boolean is a Boolean instantiation of an object class, just as an integer corresponds to an int

Since jdk1.5.0 and above, Boolean is the same as Boolean on "assignment" and
That is you: Boolean B1 = true; or Boolean b2 = true; All can.
The only thing that can be used on a Boolean is when you get a value from a list or hash table.
For example, Boolean t = false;
Map map = new HashMap ();
Map.put ("T", t);
Then you can get the value only with
Boolean T1 = (Boolean) map.get (t); The preceding can only be cast with a Boolean and cannot use Boolean.

For example:
Boolean B1 = false;
Boolean b2 = new Boolean ("false");
System.out.println (B1 = = b2); True

Differences between Boolean and Boolean types of data

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.