Remove Null Value from String array in java

前端 未结 8 663
囚心锁ツ
囚心锁ツ 2020-11-29 08:16

How to remove null value from String array in java?

String[] firstArray = {\"test1\",\"\",\"test2\",\"test4\",\"\"};

I need the \"firstArra

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 08:55

    A gc-friendly piece of code:

    public static X[] arrayOfNotNull(X[] array) {
        for (int p=0, N=array.length; p

    It returns the original array if it contains no nulls. It does not modify the original array.

提交回复
热议问题