5个回答
展开全部
public class Test {
public static void main(String[] args) {
String test = "ffd,dfdsf,fdsfds";
String[] rs = test.split(",");
for (int i = 0; i < rs.length; i++) {
System.out.println(rs[i]);
}
}
}
那应该是这样的:
public class Test {
public static void main(String[] args) {
String test = "ssssss";
StringBuffer temp = new StringBuffer();
for (int i = 0; i < test.length(); i++) {
temp.append(test.charAt(i)+",");
}
String rs = temp.substring(0,temp.length()-1);
System.out.println(rs);
}
}
public static void main(String[] args) {
String test = "ffd,dfdsf,fdsfds";
String[] rs = test.split(",");
for (int i = 0; i < rs.length; i++) {
System.out.println(rs[i]);
}
}
}
那应该是这样的:
public class Test {
public static void main(String[] args) {
String test = "ssssss";
StringBuffer temp = new StringBuffer();
for (int i = 0; i < test.length(); i++) {
temp.append(test.charAt(i)+",");
}
String rs = temp.substring(0,temp.length()-1);
System.out.println(rs);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-11-08 · 知道合伙人数码行家
关注
展开全部
String s = "ssssss";
StringBuffer a = new StringBuffer();
for (int i = 0; i <s.length(); i++) {
s.append(scharAt(i)+",");
}
String rs = a.substring(0,a.length()-1);
System.out.println(rs);
StringBuffer a = new StringBuffer();
for (int i = 0; i <s.length(); i++) {
s.append(scharAt(i)+",");
}
String rs = a.substring(0,a.length()-1);
System.out.println(rs);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
package test;
public class Test {
public static void main(String[] args) {
String s = "sssssssssssssssssssssssssss";
char[] s_arr = s.toCharArray();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s_arr.length; i++) {
if (i != s_arr.length - 1) {
sb.append(String.valueOf(s_arr[i])).append(",");
} else {
sb.append(String.valueOf(s_arr[i]));
}
}
System.err.println(sb.toString());
}
}
public class Test {
public static void main(String[] args) {
String s = "sssssssssssssssssssssssssss";
char[] s_arr = s.toCharArray();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s_arr.length; i++) {
if (i != s_arr.length - 1) {
sb.append(String.valueOf(s_arr[i])).append(",");
} else {
sb.append(String.valueOf(s_arr[i]));
}
}
System.err.println(sb.toString());
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
String s = "ssssss";
String[] s1 = s.split("");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s1.length; i++) {
if (i != s1.length - 1) {
sb.append(s1[i] + ",");
} else {
sb.append(s1[i]);
}
}
String[] s1 = s.split("");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s1.length; i++) {
if (i != s1.length - 1) {
sb.append(s1[i] + ",");
} else {
sb.append(s1[i]);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class Test{
public static void main(String[] args){
String s="ssssss";
String str="";
for(int i=0;i<s.length();i++){
if(i==s.length()-1){
str+=s.substring(i,i+1);
break;
}else{
str+=s.substring(i,i+1);
str+=",";
}
}
System.out.println(str);
}
}
public static void main(String[] args){
String s="ssssss";
String str="";
for(int i=0;i<s.length();i++){
if(i==s.length()-1){
str+=s.substring(i,i+1);
break;
}else{
str+=s.substring(i,i+1);
str+=",";
}
}
System.out.println(str);
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询