Get to know java-5.1 from scratch Why do I need access rights?

Source: Internet
Author: User

In this chapter, let's talk about why you need access rights?

1. Because it solves a problem: to separate unchanging and often changing

Package Com.ray.ch05;public class Test {private int id = 0;public int getId () {return ID;} public void setId (int id) {this.id = id;}}

From the code above we can see, id this domain is often based on the operation of constant changes, and the method get and set are basically fixed down, so the ID is private, and the Get, set method is public


2. Solve the contradiction between front and back programmers

Most of the time the backend program needs to be modified, while the front end relies on the output of the backend, so the front end often opposes back-end modifications.

With access control, you can solve this problem.

From the above code we can see, as long as the method name, the same as the return value, the same parameters, the front-end developers only need to call, and then how to modify the backend does not matter.


3. By introducing the package, you can put classes of the same function unit together to avoid erroneous calls elsewhere.


Summary: This section briefly discusses the three reasons why you need access rights.


This chapter is here, thank you.

-----------------------------------

Directory



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Get to know java-5.1 from scratch Why do I need access rights?

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.