Java 8 Enhanced wrapper class

Source: Internet
Author: User
Tags wrapper

---restore content starts---

1Java provides the corresponding wrapper class for 8 types. Because these 8 types are not classes or objects, they should not exist in Java (This is what is said here), it is emphasized that Java allows the value of the basic type directly to the corresponding wrapper class reference variable, also allows the wrapper class object to be assigned to the corresponding basic type variable.

Like what:

BYTE a=10;

BYTE b=new byte ();

b=10;//This is doable D.

a=b;//This is also possible, because the above is emphasized.

The fundamental reason here is that the person who invented Java wanted to be able to unify Java (which is made up of classes), so he wrote into his library What was not originally a class.

How does 2java implement an immutable class? The final keyword is used in Java to decorate classes, methods, and variables. A class that has been modified cannot derive a subclass, a decorated method cannot be overridden by a class, and a modified variable does not allow him to be re-assigned. This is a very powerful place, such as a critical value is fixed, so after the use of final decoration, the value is fixed in memory, with static modifier is a class variable, not decorated is an instance variable (or method), So they become a fixed value when the class is established or the method is established.

For example, the age of age in here is that he is final, so it cannot be modified in any way.

3 abstractand interface Two keywords, he defines an abstraction class and interface. Abstract classes and interfaces are common features of multiple subclasses, and abstract classes are templates for multiple classes, and interfaces define the rules that many classes should follow. It can be said that the abstract class is a teacher, the teacher taught all the students knowledge, all students learn (assuming the subclass is a very clever child), and the interface is the director or school police, he is responsible for the management of many classes let them abide by certain rules. Lambda is the most important update for JAVA8.

The essence of object-oriented is to allow the program to think like the world, to collaborate.

2

Eight types of data in Java

  

---restore content ends---

Java 8 Enhanced wrapper class

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.