String a=“name&type”;我现在想直接拿到 name值和type值应该怎么写,都是String类型。麻烦写清楚点,谢谢。
1 回答
已采纳
yanrun
TA贡献317条经验 获得超240个赞
public static void main(String[] args) {
String str = "name&type";
String separator = "&"; //设置分隔符
String[] strs = str.split(separator); //将字符串使用分隔符进行分割
for(String s : strs) {
System.out.println(s);
}
}添加回答
举报
0/150
提交
取消
