Java Collection Null getNextNullIndex(C collection)

Here you can find the source of getNextNullIndex(C collection)

Description

get Next Null Index

License

Open Source License

Declaration

public static <C extends Collection> int getNextNullIndex(C collection) throws Exception 

Method Source Code

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

import java.util.Collection;

public class Main {
    public static <C extends Collection> int getNextNullIndex(C collection) throws Exception {
        int output = -1;
        int currentLoc = 0;

        for (Object object : collection) {
            if (object == null) {
                output = currentLoc;// w  ww.  j  a v a  2 s .c o m
                break;
            }
            currentLoc++;
        }

        if (output != -1) {
            throw new Exception("Collection is full.");
        } else {
            return output;
        }
    }
}

Related

  1. countNonNull(Collection dist)
  2. countNotNull(Collection collection)
  3. getItemAtPositionOrNull(Collection collection, int position)
  4. getNumberOfNonNullElements(final Collection col)
  5. getSingleElementOrNull(Collection collection)
  6. getSizeNullSafe(final Collection collection)
  7. hasAtLeastOneNotNullElement(Collection collection)