在java的一个类中,可能含有多个构造函数,如果其中的构造函数调用其他的构造函数,不能直接写构造函数名,应该用关键字this调用。
例如:
public class Test
{
public Test(){
this(1);
}
public Test(int i)
{
System.out.println(i);
} }
本文出自 “TinyKing” 博客
在java的一个类中,可能含有多个构造函数,如果其中的构造函数调用其他的构造函数,不能直接写构造函数名,应该用关键字this调用。
例如:
public class Test
{
public Test(){
this(1);
}
public Test(int i)
{
System.out.println(i);
} }
本文出自 “TinyKing” 博客