楼上说的对,你的 this.extent=extent的意思是:
将本方法的变量extent的值赋给类变量extent(本类的全局变量)
将本方法的变量extent的值赋给类变量extent(本类的全局变量)
解决方案 »
- Swing 两个JList如何共用一个 litener
- 3-Point Gradient Fill (有图) 请问用awt实现的思路 或 有何算法实现
- 这样的代码会造成内存泄露吗?
- 关于Myeclipse不编译问题
- 求struts+fileupload 上传实例???---高分,不够再加
- 请教一下,我要个JAVA文件里用数据源连接名为BE的数据库,代码给如何写`````
- 问:又没有一种文本组件可以显示一个整型的值,但不能编辑,我用它来显示在线用户的数目。
- 一个文件搜索小工具,实用,有源码
- 请个高手帮帮忙,我一晚上都没解决这个问题!!!!!!!!!!!!!!!!
- java compile---菜鸟级
- this和static使用疑惑,谢谢!
- 一个关于异常类的问题
this.extent 表示当前类下的一个成员extent;
右边的extent把它看成相应的为一个值(大概的讲), 赋值给当前类下的成员this.extent
实例就是这个类有一个实例的对象,为这个类分配了内存,
好了,this的用处来了,我们在调用每一个方法时,其实编译器为我们多加了一个参数、这就是this指针,我们自己写得方法虽然传过N值,但实际上传了N+1个值,多出来那一个就是this。。
用来指示对像!
int x, y, radius;
public Circle(int x, int y, int radius) {
. . .
}
}The Circle class has three member variables: x, y and radius. In addition, the constructor for the Circle class accepts three arguments each of which shares its name with the member variable for which the argument provides an initial value.
The argument names hide the member variables. So using x, y or radius within the body of the constructor refers to the argument, not to the member variable. To access the member variable, you must reference it through this--the current object: class Circle {
int x, y, radius;
public Circle(int x, int y, int radius) {
this.x = x;
this.y = y;
this.radius = radius;
}
}Names of method arguments cannot be the same as another argument name for the same method, the name of any variable local to the method, or the name of any parameter to a catch clause within the same method.
比如
class A {
String s;//local s
public void b(String s){
this.s = s;
}
}这里,this.s指明了参数里(String s)传来的值付给了A的s即(local s)这里this就是指class Agood luck!
int int_val;
public XXX(int int_val) {
this.inv_val = int_val;
//因为这里int_val同名,用this就可以区分
}
public XXX(int v,Object o) {
inv_val = v;
//因为这里编译器知道,不用写this就可以区分,当然写this也不会错
}}