【发布时间】:2021-07-01 05:05:57
【问题描述】:
在java中拆分字符串:- 我尝试使用以下代码,但没有得到预期的 o/p
String[] SplitString = s.split(" ");
String s= "Apple not in Vegetable,Object,Item"
Expected o/p = Apple
Expected o/p = not in
Expected o/p = Vegetable,Object,Item
【问题讨论】:
-
你是按空格分割的,你怎么期望
not in作为单个字符串出现?这里有一个空间。 -
输出应该是 Apple \n 而不是 \n \n Vegetable,Object,Item