为什么第一个输出是错的呢 ?另外希望大神帮我推荐一个适合初学者的交流群

tengfangming 2011-06-02 05:51:40

public class StringArrayChange
{
public static void main(String[] args)
{
String a = "world";
char c[]= a.toCharArray();
for(int i=0;i<c.length;i++)
System.out.print(c[i]+'\t');
System.out.println();
String b = new String(c);
String d= new String(c,0,3);
System.out.println(b);
System.out.println(d);
}

}
...全文
39 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
kevinPai2011 2011-06-02
  • 打赏
  • 举报
回复
27357850群
demohunter 2011-06-02
  • 打赏
  • 举报
回复
你想用制表符吗?System.out.print(c[i]+"\t");才好使的啊 不然就会向楼上说的那样啊
mingchaoyan 2011-06-02
  • 打赏
  • 举报
回复
'\t' 的ascii码是9 'w'的ascii码是119 lz你这么一加就变成128了

不用什么群,csdn上有好多热心的人
mingchaoyan 2011-06-02
  • 打赏
  • 举报
回复

public class StringArrayChange {
public static void main(String[] args) {
String a = "world";
char c[] = a.toCharArray();
for (int i = 0; i < c.length; i++)
System.out.print(c[i]);
System.out.println();
String b = new String(c);
String d = new String(c, 0, 3);
System.out.println(b);
System.out.println(d);
}
}

23,407

社区成员

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

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