Access level modifiers的区别

睁着眼做梦 posted @ 2014年3月27日 16:05 in Java with tags java Access Level , 4797 阅读

Access level modifiers determine whether other classes can use a particular field or invoke a particular method. There are two levels of access control:

  • At the top level—public, or package-private (no explicit modifier).
  • At the member level—publicprivateprotected, or package-private(no explicit modifier).

  Details:  

A class may be declared with the modifier public, in which case that class is visible to all classes everywhere. If a class has no modifier (the default, also known aspackage-private), it is visible only within its own package (packages are named groups of related classes — you will learn about them in a later lesson.)

At the member level, you can also use the public modifier or no modifier (package-private) just as with top-level classes, and with the same meaning. For members, there are two additional access modifiers: private and protected. Theprivate modifier specifies that the member can only be accessed in its own class. The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package


  具体例子:  

由此可以对比member层面的两个不同: no modifier 和 protected; 其他两个(public, private)都是直白的对于此package内透明与不透明,没什么花头.

Samantha McNair 说:
2018年6月21日 01:39

All the charges have been struggling for the individuals. The nature is done for the flow of the ultius.com scam opportunities for the people. The main theme is inducted for the use of the reforms for the citizens and candidates.

NCERT Evs Sample Pap 说:
2022年9月16日 09:23

Environmental Education or Environmental Studies (EVS) was introduced from the foundation of education to enable students to understand the situations occurring around our surroundings without any difficulties. NCERT Evs Sample Paper Class 2 The subject refers to the neighbouring in which all life, also makes use of to solve day-to-day challenges involving the environmental elements.To get a complete analysis of examination question pattern and to get ready to write an exam with confidence, subject experts of the NCERT has provided the Class 2 EVS Sample Paper 2023 with study & learning material that supports all formats of exams held under Term-1, Term-2 and other types of exams for every interested candidate.

SEO 说:
2023年12月03日 03:43

토토매치 토토's encryption and multi-factor authentication ensure top-notch security.

civaget 说:
2023年12月03日 08:28 백링크하이 delivers on its promise of high-quality backlinks. My organic traffic has never been better!
civaget 说:
2023年12月08日 01:06

오피스타 is my go-to source for OP spot updates. It's comprehensive and reliable.

civaget 说:
2023年12月10日 07:12

Get ready for a fantastic time at a 유흥사이트. Whether it's a special occasion or a casual night out, enjoy every moment.

civaget 说:
2023年12月11日 06:22

Don't leave Jeju Island without trying 제주안마. It's a holistic experience that leaves you feeling renewed and invigorated.

civaget 说:
2023年12月11日 06:35

I had an amazing time exploring 부산오피 in Seomyeon. It's a must-visit for anyone seeking vibrant entertainment in Busan.

civaget 说:
2023年12月11日 06:58

에볼루션카지노's live baccarat is thrilling. The professional dealers and secure platform make it a top choice for casino enthusiasts.

civaget 说:
2023年12月11日 07:05

Security is paramount in online casinos, and 안전카지노 excels in this aspect. No concerns about fraud whatsoever.

civaget 说:
2023年12月13日 22:40

스포츠중계 is a paradise for sports enthusiasts.

civaget 说:
2023年12月14日 08:24

This will be the appropriate weblog for really wants to learn about this topic. You recognize a lot its nearly challenging to argue with you (not too I just would want…HaHa). You actually put a fresh spin using a topic thats been discussing for years. Great stuff, just fantastic! 실시간스포츠중계

civaget 说:
2023年12月16日 01:45

출장마사지 with Oga is a must-try experience. Their therapists work wonders on stress and tension.

civaget 说:
2023年12月18日 22:11

I'm not against the agree with the things you suggested. 프리카지노

civaget 说:
2023年12月19日 04:18

op사이트 순위 is my online roadmap, making website choices easy.

civaget 说:
2023年12月21日 04:35

오피가이드: Your officetel adventure awaits.

civaget 说:
2024年1月02日 02:23

티비위키 is a game-changer in the world of streaming.

civaget 说:
2024年1月13日 02:55

천안출장마사지 is your ticket to a more relaxed, healthier you.

SEO 说:
2024年1月23日 00:32

I like this site so much, saved to favorites . The Presidential Family

SEO 说:
2024年1月31日 21:12

Excellent blog right here! Also your site a lot up very fast! What web host are you the use of? Can I am getting your associate link to your host? I want my site loaded up as quickly as yours lol lpb piso wifi 10.0.0.1 pause time login

how to change iPhone 说:
2024年2月01日 02:47

Thank your for share. I hope you will share again.

drKimberly fungus tr 说:
2024年2月02日 21:48

You have a real ability for writing unique content. I like how you think and the way you represent your views in this article. I agree with your way of thinking. Thank you for sharing.

SEO 说:
2024年2月03日 23:06

Thank you for the good writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! However, how could we communicate? Büyükçekmece Escort

white garmin watch 说:
2024年2月04日 23:20

There is noticeably a bundle to find out about this. I assume you made sure nice factors in options also.

seo 说:
2024年2月06日 22:40

Perfect work you have done, this site is really cool with good information. agen murahqq

How to Turn Off Low 说:
2024年2月07日 03:57

I am glad that it turned out so well and I hope it will continue in the future because it is so worthwhile and meaningful to the community.

seo 说:
2024年2月07日 04:47

I really prize your work , Great post. 에볼루션카지노

seo 说:
2024年2月07日 05:56

A thoughtful insight and ideas I will use on my blog. You have obviously spent a lot of time on this. Well done! The Growth Matrix Reviews

seo 说:
2024年2月07日 06:12

You could certainly see your enthusiasm in the work you write. The world hopes for more passionate writers like you who aren’t afraid to say how they believe. Always go after your heart. look at this site

seo 说:
2024年2月10日 01:41

Do you wear boxers or biefs? I wana bui em. The exodus Effect Book

seo 说:
2024年2月10日 20:30

Nice post. I learn something more challenging on distinct blogs everyday. It will always be stimulating to read content off their writers and practice a little something from their store. I’d choose to use some with all the content in my small weblog whether you do not mind. Natually I’ll provide a link on your own internet weblog. Many thanks sharing. 셔츠룸

seo 说:
2024年2月12日 01:19

I think this web site has very superb composed subject material articles . Blox Fruits codes

seo 说:
2024年2月12日 02:38

Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your blog? My website is in the very same area of interest as yours and my users would really benefit from a lot of the information you present here. Please let me know if this okay with you. Regards! Nickel strip supplier

robinjack 说:
2024年5月28日 04:44

Usually, to trust a school, parents need to recognize the name of the school. AAU


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter