【发布时间】:2011-12-19 02:17:36
【问题描述】:
我知道这个问题与其他人询问 Java 属性的问题类似,这些问题的答案似乎是“不,你必须使用 getter/setter”。
我搜索了类似 C# 的 Java 属性,但到目前为止只找到了一个“命中”。而且我不确定它是财产还是其他东西。
Reading the Java Tutorial,我遇到了一些文字和代码,上面写着(**强调和评论我的):
Finally, you can use the built-in **length property** to determine the
size of any array. The code:
//notice lack of brackets after anArray.length :
System.out.println(anArray.length);
will print the array's size to standard output.
既然Array 有一个length 属性,那么Java 确实 有属性,对吧?
有人可以指出一些关于他们的文档吗?
【问题讨论】:
-
“不,你必须使用 getters/setters”:那就是 stackoverflow.com/q/2963243/545127
标签: java properties