当前位置: 代码迷 >> Java相关 >> 请看代码,请进。。
  详细解决方案

请看代码,请进。。

热度:213   发布时间:2006-11-22 10:31:42.0
请看代码,请进。。
public class Account
{
int accountId=10000;
public Account createAccount()
{
accountId++;
return this;
}
public int getAccountId()
{
return accountId;
}
public static void main(String[] args)
{
Account account=new Account();
System.out.println("账号是:"+account.createAccount().getAccountId());
}
}
请问一下,其中的 this 代表什么意思。先谢了。
搜索更多相关的解决方案: 代码  

----------------解决方案--------------------------------------------------------
return this;的意思是返回这个类的对象本身~
例如:当你在main()函数里调用了account.creatAccount()的时候,返回的还是这个Account类型的对象account~
----------------解决方案--------------------------------------------------------
  相关解决方案