在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 生日祝福语简短女友英语
13 简短新年红包祝福语大全
14 学生国庆简短的祝福语
15 生日祝福语 简短独特情话
16 学校元旦祝福语和简短
17 喜得孙子祝福语简短唯美
18 简短搞笑蛋糕生日祝福语