Java Collection Null countNotNull(Collection collection)

Here you can find the source of countNotNull(Collection collection)

Description

count Not Null

License

Open Source License

Declaration

protected static int countNotNull(Collection<String> collection) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    protected static int countNotNull(Collection<String> collection) {
        int i = 0;

        for (String item : collection) {
            if (item != null && !"!".equals(toKey(item))) {
                i++;//from w w  w .ja  va 2  s  . c o  m
            }
        }

        return i;
    }

    protected static String toKey(String text) {
        if (text == null) {
            return null;
        }

        return text.substring(0, Math.min(text.length(), 1));
    }
}

Related

  1. countNonNull(Collection dist)
  2. getItemAtPositionOrNull(Collection collection, int position)
  3. getNextNullIndex(C collection)
  4. getNumberOfNonNullElements(final Collection col)
  5. getSingleElementOrNull(Collection collection)