Split Java String into Two String using delimiter

后端 未结 7 1110
情话喂你
情话喂你 2020-12-03 18:09

I have a string that has the value of name:score. I want to split the string into two strings, string a with the value of name and str

7条回答
  •  萌比男神i
    2020-12-03 18:29

    Split creates an array with your strings in it:

    String input = "name:score";
    final String[] splitStringArray = input.split(":");
    String a = splitStringArray[0];
    String b = splitStringArray[1];
    

提交回复
热议问题