[求助]那里错了?
class TomCry{
int leg;
Tom(int n)
{
this.cry();
leg=n;
this.cry();
}
void cry()
{
System.out.println("我是Tom,我有"+leg+"条腿");
}
public static void main(String[] args)
{
Tom tom=new Tom(4);
}
}
----------------解决方案--------------------------------------------------------
这样行不.
public class TomCry
{
int leg=0;
TomCry(int n)
{
this.cry();
leg=n;
this.cry();
}
void cry()
{
System.out.println("我是Tom,我有"+leg+"条腿");
}
public static void main(String[] args)
{
TomCry tom=new TomCry(4);
}
}
----------------解决方案--------------------------------------------------------
构造函数写错了
----------------解决方案--------------------------------------------------------
想试试this,把构造函数给写错了。。。谢谢了
----------------解决方案--------------------------------------------------------