Java - Write code to Check whether all string values in given array is full and assigned.

Requirements

Write code to Check whether all string values in given array is full and assigned.

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String stringTokens = "book2s.com";
        System.out.println(isAllFull(stringTokens));
    }//from  w  ww  .  j a v a 2  s. c o  m

    /**
     * Check whether all string values in given array is full and assigned.
     * 
     * @param stringTokens
     * @return true if all string values is full and assigned.
     */
    public static boolean isAllFull(String... stringTokens) {
        if (stringTokens == null || stringTokens.length == 0) {
            return false;
        } else {
            for (String str : stringTokens) {
                if (isEmpty(str) == true) {
                    return false;
                }
            }
        }
        return true;
    }

    /**
     * Check whether given string is null or empty.
     * 
     * @param str
     * @return true if the string token is null or empty
     */
    public static boolean isEmpty(String str) {
        return (str == null || str.trim().length() == 0);
    }
}