查看: 1488|回复: 4
|
java 的问题
[复制链接]
|
|
why everytime create a class need this...
class {
get {}
set {}
} |
|
|
|
|
|
|
|
发表于 26-10-2005 04:07 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 26-10-2005 04:14 PM
|
显示全部楼层
原帖由 Imnotsad 于 26-10-2005 04:01 PM 发表
why everytime create a class need this...
class {
get {}
set {}
}
不一定每次造一个Class就需要如此,那是当你需要作出一个Javabean的时候才这样做的。 |
|
|
|
|
|
|
|
发表于 26-10-2005 07:48 PM
|
显示全部楼层
可以去找找Encapsulation的资料,是Object-oriented programming的一个很重要的技术,目的是要把Class内部的property和外部的程序码隔绝。 |
|
|
|
|
|
|
|
发表于 26-10-2005 09:12 PM
|
显示全部楼层
class XXXX{
private String password;
public String getPassword();
{
return decrypt(this.password);//Encapsulation,目的是要把Class内部的 property 的 Implementation 和外部的程序码隔绝。
}
public void setPassword(String password);
{
this.password = encrypt(password);
}
}
[ 本帖最后由 hkloke2000 于 26-10-2005 09:22 PM 编辑 ] |
|
|
|
|
|
|
| |
本周最热论坛帖子
|