String.substring vs String[].split

前端 未结 5 1867
醉梦人生
醉梦人生 2021-01-17 09:24

I have a comma delaminated string that when calling String.split(\",\") it returns an array size of about 60. In a specific use case I only need to get the valu

5条回答
  •  不知归路
    2021-01-17 10:18

    I would use something like:

    final int first = searchString.indexOf(",");
    final int second = searchString.indexOf(",", first+1);
    String result= searchString.substring(first+1, second);
    

提交回复
热议问题