class myClass
{
int x;
public myClass(int i)//constructor1
{
x = i;
}
public myClass(String s)//constructor2
{
this(Integer.parseInteger(s));// here!!!!!!!!!!!!!!!!!
}
}if i want to change constructor2
public myClass(String s)//constructor2
{
int i = Integer.parseInteger(s);
// here what should i do???????????????????????????
}
help?????????????????????????????????????????????????
{
int x;
public myClass(int i)//constructor1
{
x = i;
}
public myClass(String s)//constructor2
{
this(Integer.parseInteger(s));// here!!!!!!!!!!!!!!!!!
}
}if i want to change constructor2
public myClass(String s)//constructor2
{
int i = Integer.parseInteger(s);
// here what should i do???????????????????????????
}
help?????????????????????????????????????????????????
----------------------------
this.x=i;
2. 用this(Integer.parseInt(s));调用其它构造只能在函数第一句,
所以,下面做法行不通
int i = Integer.parseInteger(s);
this(i); //error!