逻辑问题~分解
本帖最后由 eswallow 于 2013-05-03 18:40:55 编辑 String text="a=1&&b=2&&c=3&&d=4" 如何把他拆分成2个数组String b[],String c[]
String b[]里面放 a b c d
String c[]里面放 1 2 3 4
Java
[解决办法]
public class SplitS
{
public static void main(String[] args)
{
String text = "a=1&&b=2&&c=3&&d=4";
String[] sss = text.split("&&");
String[] r1 = new String[sss.length];
String[] r2 = new String[sss.length];
for(int i = 0; i<sss.length; i++)
{
String[] temp = sss[i].split("=");
r1[i] = temp[0];
r2[i] = temp[1];
}
for (int i =0; i<sss.length; i++)
{
System.out.println(r1[i]+" "+ r2[i]);
}
}
}