Removing empty element from Array(Java)

后端 未结 5 811
遇见更好的自我
遇见更好的自我 2020-12-10 09:12

I\'m trying to remove the empty element from the array by copying the existing element to a new array. However, initialization of the new array is causing my return value to

5条回答
  •  一个人的身影
    2020-12-10 10:07

    You shouldn't compare strings using == operator. This is incorrect, because strings are objects. Use .equals() method instead, this should fix your problem.

    Rest part of your code is quite confusing, it's hard to understand what you are trying to achieve: you create new string array store each time in loop iterations, and then assign its null (by default) values to words[i]. You should elaborate your code and algorithm.

提交回复
热议问题