幼儿园工作经验:java 当中字符串的赋值问题
来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 04:48:40
我想知道如何用一个已知的字符串对另外一个字符串变量(StringBuffer)进行赋值.
我通过editor1.append(xx);这句话将字符串xx传递给方法append中的变量newString,那么该用什么函数或者方法来将该字符串赋值给另外一个字符串a[]呢?
3楼的高人,我用的是你这个方法:
myeditor[CurrentLine]=newString.getBytes();
其中myeditor[CurrentLine]的定义是这样的:
private StringBuffer[] myeditor;
但是编译之后说:
找到: byte[]
需要: java.lang.StringBuffer
myeditor[CurrentLine]=newString.getBytes();
1 错误
是哪里错了呢?
我通过editor1.append(xx);这句话将字符串xx传递给方法append中的变量newString,那么该用什么函数或者方法来将该字符串赋值给另外一个字符串a[]呢?
3楼的高人,我用的是你这个方法:
myeditor[CurrentLine]=newString.getBytes();
其中myeditor[CurrentLine]的定义是这样的:
private StringBuffer[] myeditor;
但是编译之后说:
找到: byte[]
需要: java.lang.StringBuffer
myeditor[CurrentLine]=newString.getBytes();
1 错误
是哪里错了呢?
String类的void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin);将字符从此字符串复制到目标字符数组
srcBegin - 字符串中要复制的第一个字符的索引。
srcEnd - 字符串中要复制的最后一个字符之后的索引。
dst - 目标数组。
dstBegin - 目标数组中的起始偏移量。
a="xx".getBytes();
表达的不太清楚哦,有点不明白你要问的什麼