Edited, memorised or added to reading queue

on 03-Aug-2014 (Sun)

Do you want BuboFlash to help you learning these things? Click here to log in or create user.

Flashcard 149626698

Tags
#bloch-effective-java-2ed #java #java-generics
Question
A class or interface whose declaration has one or more [...]is a generic class or interface.
Answer
(formal) type parameters

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
A class or interface whose declaration has one or more type parameters is a generic class or interface.







Flashcard 149626705

Tags
#bloch-effective-java-2ed #java #java-generics
Question
A class or interface whose declaration has one or more type parameters is a [...]class or interface.
Answer
generic

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
A class or interface whose declaration has one or more type parameters is a generic class or interface.







Flashcard 149626721

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Generic classes and interfaces are collectively known as [...].
Answer
generic types

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626737

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Each generic type defines a set of [...], which consist of the class or interface name followed by an angle-bracketed list of actual type parameters corresponding to the generic type’s formal type parameters.
Answer
parameterized types

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
Each generic type defines a set of parameterized types, which consist of the class or interface name followed by an angle-bracketed list of actual type parameters corresponding to the generic type’s formal type parameters.</bo







Flashcard 149626744

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Each generic type defines a set of parameterized types, which consist of the class or interface name followed by an angle-bracketed list of [...].
Answer
actual type parameters (corresponding to the generic type’s formal type parameters)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
Each generic type defines a set of parameterized types, which consist of the class or interface name followed by an angle-bracketed list of actual type parameters corresponding to the generic type’s formal type parameters.







Flashcard 149626764

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Each generic type defines a [...], which is the name of the generic type used without any accompanying actual type parameters
Answer
raw type

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
Each generic type defines a raw type, which is the name of the generic type used without any accompanying actual type parameters







Flashcard 149626771

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Each generic type defines a raw type, which is the
Answer
name of the generic type used without any accompanying actual type parameters

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
Each generic type defines a raw type, which is the name of the generic type used without any accompanying actual type parameters







Flashcard 149626778

Tags
#bloch-effective-java-2ed #java #java-generics
Question
What element can you put into Collection<?> ?
Answer
only null

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626789

Tags
#bloch-effective-java-2ed #java #java-generics
Question
How can you use generics in class literals, e.g. XX.class or (y instanceof XX) ?
Answer
You can't. For example List<String>.class is illegal. You have to use raw types.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626809

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
[...]List<String>
Actual type parameterString
Generic typeList<E>
Formal type parameterE
Unbounded wildcard typeList<?>
Raw typeList
Bounded type parameter<E extends Number>
Recursive type bound<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
Generic method static<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Parameterized type

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric







Flashcard 149626816

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
[...]String
Generic typeList<E>
Formal type parameterE
Unbounded wildcard typeList<?>
Raw typeList
Bounded type parameter<E extends Number>
Recursive type bound<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
Generic method static<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Actual type parameter

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asLis







Flashcard 149626823

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
Actual type parameterString
[...]List<E>
Formal type parameterE
Unbounded wildcard typeList<?>
Raw typeList
Bounded type parameter<E extends Number>
Recursive type bound<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
Generic method static<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Generic type

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asList(E[] a)Type token







Flashcard 149626830

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
Actual type parameterString
Generic typeList<E>
[...]E
Unbounded wildcard typeList<?>
Raw typeList
Bounded type parameter<E extends Number>
Recursive type bound<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
Generic method static<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Formal type parameter

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asList(E[] a)Type tokenString.class







Flashcard 149626837

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
Actual type parameterString
Generic typeList<E>
Formal type parameterE
[...]List<?>
Raw typeList
Bounded type parameter<E extends Number>
Recursive type bound<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
Generic method static<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Unbounded wildcard type

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asList(E[] a)Type tokenString.class







Flashcard 149626844

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
Actual type parameterString
Generic typeList<E>
Formal type parameterE
Unbounded wildcard typeList<?>
[...]List
Bounded type parameter<E extends Number>
Recursive type bound<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
Generic method static<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Raw type

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asList(E[] a)Type tokenString.class







Flashcard 149626851

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
Actual type parameterString
Generic typeList<E>
Formal type parameterE
Unbounded wildcard typeList<?>
Raw typeList
[...]<E extends Number>
Recursive type bound<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
Generic method static<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Bounded type parameter

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asList(E[] a)Type tokenString.class







Flashcard 149626858

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
Actual type parameterString
Generic typeList<E>
Formal type parameterE
Unbounded wildcard typeList<?>
Raw typeList
Bounded type parameter<E extends Number>
[...]<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
Generic method static<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Recursive type bound

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asList(E[] a)Type tokenString.class







Flashcard 149626865

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
Actual type parameterString
Generic typeList<E>
Formal type parameterE
Unbounded wildcard typeList<?>
Raw typeList
Bounded type parameter<E extends Number>
Recursive type bound<T extends Comparable<T>>
[...]List<? extends Number>
Generic method static<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Bounded wildcard type

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asList(E[] a)Type tokenString.class







Flashcard 149626872

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
Actual type parameterString
Generic typeList<E>
Formal type parameterE
Unbounded wildcard typeList<?>
Raw typeList
Bounded type parameter<E extends Number>
Recursive type bound<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
[...]<E> List<E> asList(E[] a)
Type tokenString.class
Answer
Generic method static

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
tml>TermExampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asList(E[] a)Type tokenString.class<html>







Flashcard 149626879

Tags
#bloch-effective-java-2ed #java #java-generics
Question
TermExample
Parameterized typeList<String>
Actual type parameterString
Generic typeList<E>
Formal type parameterE
Unbounded wildcard typeList<?>
Raw typeList
Bounded type parameter<E extends Number>
Recursive type bound<T extends Comparable<T>>
Bounded wildcard typeList<? extends Number>
Generic method static<E> List<E> asList(E[] a)
[...]String.class
Answer
Type token

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
generics terms quick reference
xampleParameterized typeListActual type parameterStringGeneric typeListFormal type parameterEUnbounded wildcard typeListRaw typeListBounded type parameterRecursive type bound>Bounded wildcard typeListGeneric method static List asList(E[] a)<span>Type tokenString.class<span><body><html>







Flashcard 149626886

Tags
#bloch-effective-java-2ed #java #java-generics
Question
How to cast raw type Set to typesafe Set using generics?

if (o instanceof Set) { // Raw type
  // here
}

Answer
Use unbounded wildcard type:

if (o instanceof Set) { // Raw type
  Set<?> m = (Set<?>) o; // Wildcard type
  // rest of the code
}


statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627007

Tags
#bloch-effective-java-2ed #java #java-generics
Question
What is the name of the property of arrays that allow us to cast Long[] to Object[], like here?

// Fails at runtime!
Object[] objectArray = new Long[1];
objectArray[0] = "I don't fit in"; // Throws ArrayStoreException

Answer
arrays are covariant

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627018

Tags
#bloch-effective-java-2ed #java #java-generics
Question
What is the name of the property of parametrized List that causes compilation error (unlike in arrays)?

// Won't compile!
List<Object> ol = new ArrayList<Long>(); // Incompatible types
ol.add("I don't fit in");

Answer
generics are invariant

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627046

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Generics are implemented by [...]. This means that they enforce their type constraints only at compile time and [...] their element type information at runtime. By contrast, array types are reified, so they can enforce their type at runtime (e.g. if you try to store a String into an array of Long, you’ll get an ArrayStoreException).
Answer
erasure / discard (or erase)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
Generics are implemented by erasure. This means that they enforce their type constraints only at compile time and discard (or erase) their element type information at runtime. By contrast, array types are reified, so they







Flashcard 149627057

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Generics are implemented by erasure. This means that they enforce their type constraints only at compile time and discard (or erase) their element type information at runtime. By contrast, array types are [...], so they can enforce their type at runtime (e.g. if you try to store a String into an array of Long, you’ll get an ArrayStoreException).
Answer
reified

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
Generics are implemented by erasure. This means that they enforce their type constraints only at compile time and discard (or erase) their element type information at runtime. By contrast, array types are reified, so they can enforce their type at runtime (e.g. if you try to store a String into an array of Long, you’ll get an ArrayStoreException).







Flashcard 149627064

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Is it legal to create an array of generic type, e.g. new List<E>[] ?
Answer
No

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627082

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Is it legal to create array of a parametrized type new List<String>[] ?
Answer
No.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627093

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Is it legal to create array of a type parameter new E[] ?
Answer
No.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627104

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Give an example how type safety could be compromised if it was legal to create arrays of parametrized types (but it is not legal).
Answer
  1. You could create an array of lists of strings:
    List<String>[] stringLists = new List<String>[1]; // this part is not legal and wouldn't compile
  2. Because arrays are covariant, you can store the array into a variable of Object[] type and then store an element of type List<Integer> (or really List<anything>) as an element of the original array without causing ArrayStoreException because at runtime List<String> and List<Integer> are simply lists
  3. So, we are in trouble - List<Integer> is stored where the compiler thought it was List<String>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627115

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Types such as E, List<E>, and List<String> are technically known as nonreifiable types. Intuitively speaking, a non-reifiable type is one whose [...]
Answer
runtime representation contains less information than its compile-time representation.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627126

Tags
#bloch-effective-java-2ed #java #java-generics
Question
The only parameterized types that are reifiable are [...]. It is legal, though infrequently useful, to create arrays of such types.
Answer
unbounded wildcard types such as List<?> and Map<?,?>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627141

Tags
#bloch-effective-java-2ed #java #java-generics
Question
For generic methods, the type parameter list, which declares the type parameter, goes [...].
Answer
between the method’s modifiers and its return type

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627152

Tags
#bloch-effective-java-2ed #java #java-generics
Question

public interface Comparable<T> {
   int compareTo(T o);
}

The type bound <T extends Comparable<T>> may be read as [...]
Answer
for every type T that can be compared to itself (mutual comparability)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627167

Tags
#bloch-effective-java-2ed #java #java-generics
Question

// Wildcard type for parameter that serves as an E producer - produces Es onto a Stack from external Iterable
public void pushAll(Iterable<...> src) {
  for (E e : src)
    push(e);
}

what kind of bounded wildcard do we need here for Iterable (producer)?
Answer
Iterable<? extends E>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627180

Tags
#bloch-effective-java-2ed #java #java-generics
Question

// Wildcard type for parameter that serves as an E consumer - it consumes from the Stack to external collection
public void popAll(Collection<...> dst) {
  while (!isEmpty())
    dst.add(pop());
}

what kind of bounded wildcard do we need here for Collection (consumer)?
Answer
Collection<? super E>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627375

Tags
#bloch-effective-java-2ed #java #java-generics
Question
What does PECS mnemonic stand for?
Answer
producers extend, consumers super - it is about wildcard types

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627386

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Which is a better version?

public static <E> Set<E> union(Set<? extends E> input1, Set<? extends E> input2)  { /* .. */ }

public static <E> Set<? super E> union(Set<? extends E> input1, Set<? extends E> input2) { /* .. */ }

Answer
The first one is better. Do not use wildcard types as return types. Rather than providing additional flexibility for your users, it would force them to use wildcard types in client code.

public static <E> Set<E> union(Set<? extends E> input1, Set<? extends E> input2)  { /* .. */ }


statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627401

Tags
#bloch-effective-java-2ed #java #java-generics
Question
If type inference does not work, like here:

public static <E> Set<E> union(Set<? extends E> s1, Set<? extends E> s2) { /* ... */ }

Set<Integer> integers = ... ;
Set<Double> doubles = ... ;
Set<Number> numbers = Union.union(integers, doubles); // does not compile

How can you make the program compile?
Answer
Use explicit type parameter:

Set<Number> numbers = Union.<Number>union(integers, doubles);


statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627412

Tags
#bloch-effective-java-2ed #java #java-generics
Question
How would you fix the declaration using PECS rule?
public static <T extends Comparable<T>> T max(List<T> list)
Answer
public static <T extends Comparable<? super T>> T max(List<? extends T> list)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627423

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Comparables are always consumers, so you should always use [...] in preference to Comparable<T>.
Answer
Comparable<? super T>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627434

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Why would List<ScheduledFuture<?>> be rejected by a method:
public static <T extends Comparable<T>> T max(List<T> list)
but accepted (as intended) by this:
public static <T extends Comparable<? super T>> T max(List<? extends T> list)
?
Answer
java.util.concurrent.ScheduledFuture does not implement Comparable<ScheduledFuture>. Instead, it is a subinterface of Delayed, which extends Comparable<Delayed>. In other words, a ScheduledFuture instance isn’t merely comparable to other ScheduledFuture instances; it’s comparable to any Delayed instance, so we have to say Comparable<? super T>. Delayed is super of ScheduledFuture. It seems that the second part, List<? extends T> as a producer does not make any difference.

basically:
ScheduledFuture extends Comparable<Delayed>
where Delayed is super of ScheduledFuture

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627445

Tags
#bloch-effective-java-2ed #java #java-generics
Question
a static method to swap two indexed items in a list:
public static <E> void swap(List<E> list, int i, int j);

How would you write it with a wildcard?
Answer
public static void swap(List<?> list, int i, int j);

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627456

Tags
#bloch-effective-java-2ed #java #java-generics
Question
a static method to swap two indexed items in a list:
public static void swap(List<?> list, int i, int j);

How would you write it with a type parameter?
Answer
public static <E> void swap(List<E> list, int i, int j);

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Article 149627467


#bloch-effective-java-2ed #java #java-generics #p139

There is a duality between type parameters and wildcards, and many methods can be declared using one or the other.



Flashcard 149627476

Tags
#bloch-effective-java-2ed #java #java-generics
Question
There is a duality between [...]and wildcards, and many methods can be declared using one or the other.
Answer
type parameters

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
There is a duality between type parameters and wildcards, and many methods can be declared using one or the other.







Flashcard 149627483

Tags
#bloch-effective-java-2ed #java #java-generics
Question
There is a duality between type parameters and [...], and many methods can be declared using one or the other.
Answer
wildcards

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
Open it
There is a duality between type parameters and wildcards, and many methods can be declared using one or the other.







Flashcard 149627490

Tags
#bloch-effective-java-2ed #java #java-generics
Question
When a class literal is passed among methods to communicate both compile-time and runtime type information, it is called a [...]
Answer
type token

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627501

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Class was generified in release 1.5. The type of a class literal is no longer simply Class, but [...], for example object String.class is of type [...]
Answer
Class<T>, Class<String>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs