Java Array Empty Check isNullOrEmpty(String[] s)

Here you can find the source of isNullOrEmpty(String[] s)

Description

is Null Or Empty

License

Apache License

Declaration

public static boolean isNullOrEmpty(String[] s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static final String EMPTY_STRING = "";

    public static boolean isNullOrEmpty(String[] s) {

        if ((s == null) || (s.length == 0))
            return true;

        for (int i = 0; i < s.length; i++) {

            if (!isNullOrEmpty(s[i])) {
                return false;
            }//from ww  w. j av  a 2s. co m
        }

        return true;
    }

    public static boolean isNullOrEmpty(List<String> input) {
        return (input == null) ? true : isNullOrEmpty(input.toArray(new String[input.size()]));
    }

    public static boolean isNullOrEmpty(String s) {
        return (s == null) || s.equals(EMPTY_STRING);
    }
}

Related

  1. isNotEmpty(T[] array)
  2. isNotEmpty(T[] array)
  3. isNotNullAndNotEmpty(final Object[] array)
  4. isNotNullOrEmpty(T[] array)
  5. isNullOrEmpty(Object[] array)
  6. isNullOrEmpty(T[] array)
  7. isNullOrEmptyOrFirstElementBlank(String[] values)
  8. normalizeTokens(String[] tokens, boolean removeEmpty)
  9. nullOrEmpty(Object[] array)