没有变,看了源码 /** * @throws IndexOutOfBoundsException {@inheritDoc} */ @Override public StringBuilder insert(int offset, char c) { super.insert(offset, c); return this; }
是不是其他地方报错了 看了一下8的API StringBuilder insert(int offset, boolean b) Inserts the string representation of the boolean argument into this sequence. 有这个方法,参数也没有问题。你把代码 和 抛出的异常 粘全了,全部贴出来看看
package mi;public class TTT { public static void main(String[] args) { StringBuilder sb = new StringBuilder("sdfsf"); char d = 'd'; System.out.println(d); sb.insert(0, d); System.out.println(sb); } }
/**
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@Override
public StringBuilder insert(int offset, char c) {
super.insert(offset, c);
return this;
}
看了一下8的API
StringBuilder insert(int offset, boolean b)
Inserts the string representation of the boolean argument into this sequence.
有这个方法,参数也没有问题。你把代码 和 抛出的异常 粘全了,全部贴出来看看
{
public static void main(String[] args)
{
StringBuilder sb = new StringBuilder("sdfsf");
char d = 'd';
System.out.println(d);
sb.insert(0, d);
System.out.println(sb);
}
}