当前位置: 技术问答>java相关
如何将字符串china|japan|usa|korea中的国家名取出并存进String[]里
来源: 互联网 发布时间:2015-09-21
本文导语: 如何将字符串china|japan|usa|korea中的国家名取出并存进String[]里 | String tmpStr = "china|japan|usa|korea"; StringTokenizer s=new StringTokenizer(tmpStr,"|"); String county[] = new String[4]; int i = 0; while...
如何将字符串china|japan|usa|korea中的国家名取出并存进String[]里
|
String tmpStr = "china|japan|usa|korea";
StringTokenizer s=new StringTokenizer(tmpStr,"|");
String county[] = new String[4];
int i = 0;
while (s.hasMoreTokens()){
String ll = s.nextToken("|");
county[i] = ll;
System.out.println(county[i]);
i++;
}
StringTokenizer s=new StringTokenizer(tmpStr,"|");
String county[] = new String[4];
int i = 0;
while (s.hasMoreTokens()){
String ll = s.nextToken("|");
county[i] = ll;
System.out.println(county[i]);
i++;
}