怎样把字符变量str的各个字符赋到数组str[]里?

连帆 2004-04-10 07:37:26
RT
...全文
111 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sniperlei 2004-04-11
  • 打赏
  • 举报
回复
String aa = "asdfasdkjsdf";
char[] ee = new char[aa.length()];
ee = aa.toArrayChar();
qqbz 2004-04-10
  • 打赏
  • 举报
回复
你所说的字符变量是指字符串String嘛?它有直接的方法。
DESL 2004-04-10
  • 打赏
  • 举报
回复
public class work {
public static void main(String args[])
{
String str1[]=new String[80];
String str="abcdefg";
int mm=7;
for(int i=0;i<mm;i++)
{
str1[i]=str.substring(i,i+1);
System.out.print(" " + str1[i]);
}

}
}
FutureStonesoft 2004-04-10
  • 打赏
  • 举报
回复
public class INSTR
{
public static void main(String[] args)
{
char[] cstr=new char[80];
String abc=new String("hello world");
abc.getChars(0,abc.length(),cstr,0);
//这样就将abc字符串中的字符存入到cstr数组中了
}
}
jinbuquan 2004-04-10
  • 打赏
  • 举报
回复
getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
Copies characters from this string into the destination character array.

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧