String b22= new String(c2, 0, c);
System.out.println(b22);
今天 发现 这样写会 影响下面代码运行 ,也不报错
System.out.println(new String(c2, 0, c));
这样就没事
什么原理?
会有什么影响,应该都可以啊
看起来没啥毛病~有没有完整点的代码
听君一席话,胜听一席话
从源码上,没有发现任何影响啊
```java
public String(char value[]) {
this(value, 0, value.length, null);
}
/**
* Allocates a new {@code String} that contains characters from a subarray
* of the character array argument. The {@code offset} argument is the
* index of the first character of the subarray and the {@code count}
* argument specifies the length of the subarray. The contents of the
* subarray are copied; subsequent modification of the character array does
* not affect the newly created string.
*
* @param value
* Array that is the source of characters
*
* @param offset
* The initial offset
*
* @param count
* The length
*
* @throws IndexOutOfBoundsException
* If {@code offset} is negative, {@code count} is negative, or
* {@code offset} is greater than {@code value.length - count}
*/
public String(char value[], int offset, int count) {
this(value, offset, count, rangeCheck(value, offset, count));
}
```