-
Notifications
You must be signed in to change notification settings - Fork 0
Java tutorial
illyfrancis edited this page Jul 18, 2013
·
14 revisions
ListIterator<E>
-
- Immutable collections, instead of unmodifirable
- ImmuatableList, Set, SortedSet, Map, (SortedMap - oneday)
- immutable vs unmodifiable
- immutability guarantee, easier to use, faster, less memory
- E.g.
- constant set using JDK (11:55)
- a little better
Collections.unmodifiableSet( new LinkedHashSet<Integer>( Arrays.asList(...))); - ImmutableSet LUCKY_NUMBERS = ImmutableSet.of(4,8,15...);
- of() <- java.util.EnumSet pattern (** check it out**)
- constant map -
ImmutableMap<String, Integer> ENG_TO_INT = ImmutableMap.with("four", 4)...build()(15:16) - Defensive copies
-
ImmutableSet.copyOf(numbers)(17:10)
-
- factories
- ImmutableSet.of() (== Collections.emptyset ?)
- ImmutableSet.of(a) (== Collections.singleton?)
- ImmutableSet.of(a, b, c)
- ImmutableSet.copyOf(someIterator);
- ImmutableSet.copyOf(someIterable);
- static final ImmutableMap<Integer, String> MAP = ImmutableMap.of(1, "one", 2, "two");
- there should be a builders pattern (check current imp)
- Don't take nulls!!!
- Immutable collections, instead of unmodifirable
-
Five ways to max NIO and NIO2
- File change notification (Watch Service API)
- Selectors and asynchronous I/O
- Channels
- Memory mapping
- Character encoding and searching
- Oracle tutorial
- Usage of
ConcurrentHashMapwithin Spring service class SO