The textbook examples are:
- Activity Scheduling
- Fractional Knapsack Problem (but not 0-1 Knapsack Problem)
- Huffman Codes
- Dijkstra's Algorithm
My collection of technical interview topics, questions, puzzles, and riddles.
public abstract class Enum<E extends Enum<E>>
<E extends Enum<E>>
? What would happen if it were declared as <E extends Enum>
instead?public enum CardSuit { HEARTS, CLUBS, DIAMONDS, SPADES }
public class CardSuit extends Enum<CardSuit>....
<E extends Enum>
were used instead, that would still be the case, but some information would be lost. The type parameter E is mentioned in three places in Enum:E extends Enum
, then the Comparable interface is only aware of Comparable<Enum>
instead of Comparable<CardSuit>
. So E extends Enum<E>
contains some extra information, making it more typesafe.