在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 18岁的祝福语简短
12 周二祝福语大全简短
13 企业励志拜年祝福语简短
14 初八的祝福语简短
15 团体年会祝福语简短霸气
16 简短有内涵的祝福语
17 姥爷生日祝福语简短精辟
18 猪年元旦祝福语简短创意