当前位置: 技术问答>一个linux shell编程求素数问题 高手帮帮忙啊
iis7站长之家
帮帮忙了,字符串问题?
来源: 互联网 发布时间:2015-01-26
本文导语: 我有一字符串 String aaa="a,b,c,d"; 我想根据aaa 的串,生成一个类似下列的串 String bbb="a=b,b=c,c=d,d=a"; 请问,如何作呀? | public String ooo() { StringTokenizer aaa = new StringTokenizer("a,b,c,d...
我有一字符串
String aaa="a,b,c,d";
我想根据aaa 的串,生成一个类似下列的串
String bbb="a=b,b=c,c=d,d=a";
请问,如何作呀?
String aaa="a,b,c,d";
我想根据aaa 的串,生成一个类似下列的串
String bbb="a=b,b=c,c=d,d=a";
请问,如何作呀?
|
public String ooo()
{
StringTokenizer aaa = new StringTokenizer("a,b,c,d",",");
String s ="";
String d = ",";
String y = "=";
boolean b = true;
String first="",tmp="";
while (aaa.hasMoreTokens())
{
if (b)
{
b = false;
first = aaa.nextToken();
s = s + first +y;
}
else
{
tmp = aaa.nextToken();
s = s+ tmp+d+tmp+y;
}
}
s = s + first;
return s;
}
{
StringTokenizer aaa = new StringTokenizer("a,b,c,d",",");
String s ="";
String d = ",";
String y = "=";
boolean b = true;
String first="",tmp="";
while (aaa.hasMoreTokens())
{
if (b)
{
b = false;
first = aaa.nextToken();
s = s + first +y;
}
else
{
tmp = aaa.nextToken();
s = s+ tmp+d+tmp+y;
}
}
s = s + first;
return s;
}