在Java中用逗号(,)分割字符串
假设以下是我们的字符串。
String str = " This is demo text, and demo line!";
要用逗号分割字符串,请使用split()Java中的方法。
str.split("[,]", 0);以下是完整的示例。
示例
public class Demo { public static void main(String[] args) { String str = "This is demo text, and demo line!"; String[] res = str.split("[,]", 0); for(String myStr: res) { System.out.println(myStr); } }}输出结果
This is demo text and demo line!
热门推荐
10 传统新婚祝福语创意简短
11 简短大气的狗年祝福语
12 低调祝福语简短10字
13 3岁孩子祝福语简短
14 Q穷人结婚祝福语简短
15 短祝福语简短暖心
16 离校退群祝福语简短
17 结婚祝福语粤语大全简短
18 简短送嫂子生日祝福语