Java Objects and encapsulation

Source: Internet
Author: User

Benefits of object-oriented design and development programs for the purpose of software appearance
Use computer language to describe real world communication more smoothly
Solving real-world problems with computers to improve design and development efficiency

Object-oriented thought description → Object-oriented world
In accordance with human thinking habits

From the reality of the abstraction of the three-step class
1 Find out the kind of it
2 Find out its properties
3 Find out what he's doing.


Call static mode 1: Instantiate an object. Object. static method (); static property
Call Static Mode 2: Class name. property or method

Static code blocks can only assign values to static properties

Note that code blocks are always used to assign an initial value to a static property, which is never preceded by a construction method.
Common Properties: Instance variables

Any variable or code in the program is automatically allocated by the system at compile time to store the memory.

Static properties: Class variables
The so-called static variable means that the memory allocated after compilation is always present
This space is not freed until the program exits memory, that is, as long as the program is running, the memory remains

The static method has several limitations
They can only invoke other static methods.
They can only access static data
You cannot use any of the reference methods of this or super


One of the three main features of object-oriented ___ Package

The concept of encapsulation
Hides some information about a class inside a class, does not allow direct access to external programs, but implements operations and access to hidden information through the methods provided by the class

Benefits of Encapsulation
Receipts can only be accessed by a prescribed method
Hiding the implementation details of a class
Easy to join control statements
Easy to modify the implementation

Package shortcut keys Shift+alt+s+r
ALT + A

Java Objects and encapsulation

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.