Write code to Check whether all string values in given array is null or empty.
//package com.book2s; public class Main { public static void main(String[] argv) { String stringTokens = "book2s.com"; System.out.println(isAllEmpty(stringTokens)); }/*from ww w. j a va 2s . c o m*/ /** * Check whether all string values in given array is null or empty. * * @param stringTokens * @return true if all string values is null or empty. */ public static boolean isAllEmpty(String... stringTokens) { if (stringTokens != null && stringTokens.length > 0) { for (String str : stringTokens) { if (isEmpty(str) == false) { 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); } }