java modifier differences

Source: Internet
Author: User

Public can be accessed by all classes in the same project, with project visibility, maximum access rights
Private member variables and methods can only access classes that have class visibility in their defined classes
Protected can be accessed by a class in a package, accessed by subclasses from different packages in the same project)
The default (friendly) can be accessed by a class in a package. With package visibility

Steps for encapsulation:
Modify the visibility of a property-private
Create a public Getter/setter method for the property of the read (get) write (set) shortcut key: Shift+alt+s
To judge the legality of attribute value by adding attribute control statement in Getter/setter method

java modifier differences

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.