Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the access modifier of Java

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces you how to understand the Java visit modifier, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Java access modifiers, such as public, private, protect, default, etc.

The scope can look directly at the above and say nothing more, let's just talk about the use scenario. There is a saying that I know the truth, but I can't use it. There are also many friends in the group who say they don't know how to use it, so we will also bring the use scene in the future. Of course, the knowledge of knife is also limited. I will share what I know, and we can share it together.

Private:

Generally used in static member constants such as

Public static final String MINI= "programmer Learning Camp"

Private:

From the encapsulation point of view, the suggested variables are defined as private, and then need to be accessed by the outside world, exposing a get method

Private String mini = "programmer learning base"; public String geMini () {return mini;}

Protect:

Commonly used in architecture design to store variables common to subclasses

Public class BaseXXX {protected String mini;} public class SubXXX extends BaseXXX {public String getMini () {return mini;}} access modifiers on how to understand Java are shared here. I hope the above can be of some help and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report