Converting a sentence string to a string array of words in Java

后端 未结 16 2457
余生分开走
余生分开走 2020-12-01 00:04

I need my Java program to take a string like:

\"This is a sample sentence.\"

and turn it into a string array like:

{\"this\         


        
16条回答
  •  半阙折子戏
    2020-12-01 00:26

    Most of the answers here convert String to String Array as the question asked. But Generally we use List , so more useful will be -

    String dummy = "This is a sample sentence.";
    List wordList= Arrays.asList(dummy.split(" "));
    

提交回复
热议问题