Java Reference
In-Depth Information
List<?>[] invokeAll = new List<?>[] {
new ArrayList<Integer>(),
new LinkedList<String>(),
new Vector<Integer>()};
for (List<?> list : invokeAll) {
System.out.println(display(list));
}
}
}
Applicability
Ambiguous uses of overloading can lead to unexpected results.
Bibliography
[API 2013]
Interface
Collection<E>
[Bloch 2008]
Item 41, “Use Overloading Judiciously”
[Tutorials 2013]
Defining Methods
73. Never confuse the immutability of a reference with that of the
referenced object
Immutability helps to support security reasoning. It is safe to share immutable objects
without risking modification by the recipient [Mettler 2010].
Programmers often incorrectly assume that declaring a field or variable
final
makes
the referenced object immutable. Declaring variables that have a primitive type to be
fi-
nal
does prevent changes to their values after initialization (by normal Java processing).
However, when the variable has a reference type, the presence of a
final
clause in the
declaration only makes
the reference itself
immutable. The
final
clause has no effect on
the referenced object. Consequently, the fields of the referenced object may be mutable.
For example, according to the JLS, §4.12.4, “
final
Variables” [JLS 2013],