Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <A> List<A> flatten(List<List<A>> nestedLists);
- flatten(nestedList.map(l -> l.map(any_function)))
- ≡ flatten(nestList).map(any_function)
- <T> T broken { return new T(); }
- void doStuff(List<Integer> collection) {
- }
- void doStuff(List<String> collection) // ERROR: a method cannot have
- // overloads which only differ in type parameters
- public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)
- public List<Integer> XXX(final List<Integer> l);
- public <T> List<T> XXX(final List<T> l);
- public class GenericClass<T>
- {
- private Class<T> targetClass;
- public GenericClass(Class<T> targetClass)
- {
- this.targetClass = targetClass;
- }
- public T newT () {
- try {
- return targetClass.newInstance();
- } catch(/* I forget which exceptions can be thrown here */) { ... }
- }
- private T value;
- /** @throws ClassCastException if object is not a T */
- public void setValueFromObject (Object object) {
- value = targetClass.cast(object);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement