Collection:コレクションが空かどうか検査する


import java.util.Collection;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Collection c = new ArrayList();
    System.out.println(c + " is Empty ? > " + c.isEmpty());
    c.add("hoge");
    c.add("foo");
    c.add("bar");
    System.out.println(c + " is Empty ? > " + c.isEmpty());
  }
}