import java.util.*; public class EmptySingletonMap { void testEmpty() { List objects = Collections.emptyList(); for (Object o : objects) { System.out.println("hello"); } } void testMixed(int x) { Collection strings; if(x > 10) { strings = Collections.singleton("foo"); } else if(x > 6) { strings = Collections.emptyList(); } else if(x > 2) { strings = Collections.singletonList("bar"); } else { strings = Arrays.asList("a", "b", "c"); } if(strings.size() >= 2 && x > 3) { System.out.println("never"); } } void testMap(boolean b) { Map map; if (b) { map = Collections.emptyMap(); } else { map = Collections.singletonMap("a", "b"); } if(b && map.isEmpty()) { System.out.println("true"); } if(!b && map.size() == 1) { System.out.println("??"); } } }