Write the code to process the list of words and trim any spaces out of the words

后端 未结 2 1951
孤街浪徒
孤街浪徒 2021-01-29 13:13

This code is supposed to check through an array of strings and see if there is a space between a word. Here is an example: {“every”, “near ing”, “ checking”, “food “, “stand”, “

相关标签:
2条回答
  • 2021-01-29 13:55

    maby this wil work

       public static String[] removeSpace(String[] ans) {
            for(String s:ans){
                while(s.contains(" ")){
                    s = s.split(" ")[0] + s.split(" ")[1];
                }
            }
            return ans;
        }
    
    0 讨论(0)
  • 2021-01-29 13:58

    You can try something like this:

    for(int i = 0; i<arr.length; i++) {
        arr[i] = arr[i].replace(" ", "");
    }
    
    0 讨论(0)
提交回复
热议问题