class ServerSocket{
....
public ServerSocket(int port) throws IOException {
this(port, 50, null);
}
....
}我知道这个关键字用于表示活动对象或当前对象。在这段代码中," this“的意思是什么?我从(这里)获得了这段代码
发布于 2015-07-31 09:47:53
在代码片段中,this(port, 50, null)表示对同一个类中的构造函数的显式调用,该类具有三个参数,其中两个参数传递硬编码参数(50和null)。
发布于 2015-07-31 09:48:13
this(port, 50, null);的意思是调用当前类的构造函数,该构造函数以int, int, Object (我猜)为参数。this引用当前的Object。在这里,它用于从其他构造函数调用构造函数,即从ServerSocket(int port, int num, Object x)调用ServerSocket(int port)构造函数。
发布于 2015-07-31 09:49:08
this(port, 50, null)调用当前类构造函数。
@this关键字
https://stackoverflow.com/questions/31743130
复制相似问题