
586 • Java Programming
List LL = Collections.EMPTY_LIST;
//LL.add(0,”hello”);line generates error
show(“\nLL.isEmpty():” + LL.isEmpty());
Set S = Collections.EMPTY_SET;
//S.add(“hello”);line generates error
show(“\nS.isEmpty():” + S.isEmpty());
Map M = Collections.EMPTY_MAP;
//M.put(“hello”,”bye”);line generates error
show(“\nM.isEmpty():” + M.isEmpty());
}
}
OUTPUT:
LL.isEmpty():true
S.isEmpty():true
M.isEmpty():true
Explanation: The static constants EMPTY_LIST, EMPTY_SET and EMPTY_MAP represent empty
immutable list, set and map, respectively. Rest is simple to understand.
18.12 PONDERABLE ...