public String(String original) {
int size = original.count;
char[] originalValue = original.value;
char[] v;
if (originalValue.length > size) {
// The array representing the String is bigger than the new
// String itself. Perhaps this constructor is being called
// in order to trim the baggage, so make a copy of the array.
v = new char[size];
System.arraycopy(originalValue, original.offset, v, 0, size);
} else {
// The array representing the String is the same
// size as the String, so no point in making a copy.
v = originalValue;
}
this.offset = 0;
this.count = size;
this.value = v;
}
标记出的if语句什么时候会得到执行,我怎么觉得它不可能执行呢!
int size = original.count;
char[] originalValue = original.value;
char[] v;
if (originalValue.length > size) {
// The array representing the String is bigger than the new
// String itself. Perhaps this constructor is being called
// in order to trim the baggage, so make a copy of the array.
v = new char[size];
System.arraycopy(originalValue, original.offset, v, 0, size);
} else {
// The array representing the String is the same
// size as the String, so no point in making a copy.
v = originalValue;
}
this.offset = 0;
this.count = size;
this.value = v;
}
标记出的if语句什么时候会得到执行,我怎么觉得它不可能执行呢!
解决方案 »
- 继承机制和接口机制的讨论
- 麻烦看一下这个程序,不知道问题出在哪儿,运行时总Exception in thread "main" java.lang.NullPointerException
- 如何用java处理图像的分辨率问题
- [高分求解]Graphics问题,在鼠标drag的画线太闪了,请高人指点指点~ [有代码]
- j%2==0&&j<i.length
- ireport分页时,打印预览时为什么第二页的内容会在第一页显示?
- 选定区域截图
- 字符转ASCII的问题
- 请问 String host 是(如 www.sina.com.cn )吗 有192.9.200.250 怎么产生 intAddress
- 急啊 ?????
- 怎么实现eclipse里面那种各个面板可以缩放的效果?
- hashmap中equals() 和hashcode(),请教
字符串的长度用length().
数组的长度用length.
length是长度
size是大小
int size = original.count; 其中count是什莫呢?求original的长度话,应该写成
int size = original.length();
new String("123");
if (originalValue.length > size)
难道就会执行?
size是0?
看这个帖子吧