Results 1 to 2 of 2
  1. #1
    albertkao is offline Member
    Join Date
    Apr 2010
    Posts
    9
    Rep Power
    0

    Default Test for all empty Strings in LinkedHashMap<String,ArrayList<String>

    For the LinkedHashMap<String,ArrayList<String> data type, how to find out whether all the Strings in ArrayList are empty/null?

    I tried the following code:
    Java Code:
    public void setProductList(LinkedHashMap<String,ArrayList<String>> productList) {
       Set st = productList.keySet();
       Collection<ArrayList<String>> st2 = productList.values();
       // what should be the code to find out whether all the Strings in st2 are empty/null?
    
       System.out.println("productList " +productList + " size " + productList.size() );
       System.out.println("st " + st.size());
       System.out.println("st2 size " + st2.size());
       System.out.println("st2 " + st2);
       System.out.println("st2 null " + st2.containsAll(null));
    }
    Output is:
    productList {PC=[], Mac=[]} size 2
    st 2
    st2 size 2
    st2 [[], []]

    What should be the code to find out whether all the Strings in st2 are empty/null?
    Last edited by albertkao; 11-04-2010 at 06:30 PM.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,987
    Rep Power
    9

Similar Threads

  1. How to match arrayList with a String?
    By Lund01 in forum Advanced Java
    Replies: 2
    Last Post: 10-14-2010, 02:07 PM
  2. Problem with empty search string
    By virendra in forum Lucene
    Replies: 0
    Last Post: 01-06-2010, 10:42 AM
  3. how to at strings to a string like a table
    By petrosgraf in forum New To Java
    Replies: 14
    Last Post: 09-24-2009, 12:00 AM
  4. NumberFormatException: empty String
    By svpriyan in forum New To Java
    Replies: 1
    Last Post: 08-12-2009, 10:46 AM
  5. Putting a string into ArrayList<String>
    By k4ff1n34dd1c7 in forum New To Java
    Replies: 5
    Last Post: 03-23-2009, 05:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •