访问符和访问修饰符的区别 [英] Difference between access specifier and access modifier

查看:311
本文介绍了访问符和访问修饰符的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上阅读和周围我听到人们说

I've read around on the internet and I've heard people say

访问说明::

访问说明符决定如何领域
访问是
其他类代码。从
访问范围完全访问完全
无法访问。您可以选择
声明一个字段的访问
说明关键字:公共,私有,
或保护

The access specifier determines how accessible the field is to code in other classes. Access ranges from totally accessible to totally inaccessible. You can optionally declare a field with an access specifier keyword: public, private, or protected.

访问修饰符::

您可以选择性地声明场
与修饰符关键字:最终或
挥发性和/或静态和/或
短暂的,抽象的,等等。

You can optionally declare a field with a modifier keyword: final or volatile and/or static and/or transient, abstract, etc.

有什么不同呢?因为访问修饰符和访问说明大多数定义说明同样的事情..这似乎很暧昧。

Is there any difference at all? Because most definitions for access modifiers and access specifiers state the same thing.. which seems so ambiguous.

推荐答案

在这种情况下,你能想到的访问说明的作为的保护符的 - 他们指定的变量可以被访问。相比之下,获得的修饰的是完全不同的;他们指定的如何的变量应该(或不应该)访问;例如。只读,挥发性等

In this context, you can think of access specifiers as protection specifiers -- they specify where a variable can be accessed from. By contrast, access modifiers are completely different; they specify how variables should (or should not) be accessed; e.g. read-only, volatile, etc.

即,可变可以是公共但只读,或者它可以是私有和可写 - 访问符没什么做的修饰词。

i.e., a variable can be public but read-only, or it can be private and writable -- the access specifiers have nothing to do with the modifiers.

不过,我有点惊讶的是,术语是为了C#,因为微软实际上是调用公共私人 访问修饰符 ,并呼吁挥发性只读只是简单的的 改性剂

However, I'm a little surprised that the terminology is for C#, since Microsoft actually calls public and private "access modifiers", and it calls volatile and readonly just plain "modifiers".

这篇关于访问符和访问修饰符的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆