日期:2014-05-18  浏览次数:20986 次

请问下面的:this(null,0,url_link)怎么理解

public class Url 
{
private Url father_url = null;
private int current_depth = 0;
private Uri url_link ;
 

  public Url(Uri url_link):this(null,0,url_link)
  {
   
  }

public Url(Url father_url, int current_depth, Uri url_link)
  {
  this.father_url = father_url;
  this.current_depth = current_depth;
  this.url_link = url_link;
}
}

------解决方案--------------------
构造函数问题
Url(Uri url_link):this(null,0,url_link)就是会自动调用另一个构造
Url(Url father_url, int current_depth, Uri url_link),传入参数为null,0,url_link
------解决方案--------------------
这个叫做constructor chaining,就是指定了this(null,0,url_link)后,执行完Url(Uri url_link)之后,就执行Url(Url father_url, int current_depth, Uri url_link)