关于Java API的String类的构造方法public String(String s)的源代码的疑问
publicString(Strings){inti=s.count;charac[]=s.value;charac1[];if(ac.length>i)//这里ac.l...
public String(String s)
{
int i = s.count;
char ac[] = s.value;
char ac1[];
if(ac.length > i) //这里ac.length的值不就一定等于s.count吗?两者不是一回事吗?怎么还判断大小呢?
{
ac1 = new char[i];
System.arraycopy(ac, s.offset, ac1, 0, i);
} else
{
ac1 = ac;
}
offset = 0;
count = i;
value = ac1;
} 展开
{
int i = s.count;
char ac[] = s.value;
char ac1[];
if(ac.length > i) //这里ac.length的值不就一定等于s.count吗?两者不是一回事吗?怎么还判断大小呢?
{
ac1 = new char[i];
System.arraycopy(ac, s.offset, ac1, 0, i);
} else
{
ac1 = ac;
}
offset = 0;
count = i;
value = ac1;
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询