Я закончил изучать дженерики, и мне было нелегко. Тем не менее, я это понял. Вот что я понял. Я хочу, чтобы вы поправили меня, где я ошибаюсь, и ответили на несколько вопросов :) .
public class LinkedList<T> {
//class definition
}
public class LinkedList<T extends Object> {
//class definition
}
public class LinkedList<T extends Object & java.lang.Serializable> {
//class definition
}
public class LinkedList<T> implements Iterable<T> {
//class definition
}
Itarator<T>
и перегружает hasNext(), next() и remove().Questions
1. Please explain the meaning of this in simple words and with an example, if possible:
public class
BinaryTree<T extends Comparable<? super T>>
what replaces the ?
2. I want to write the above mentioned LinkedList<> class to a file using the writeObject() method. so I declare it as
public class LinkedList<T extends Object> implements Serializable {
//methods and data members
private class Node implements Serializable { //inner class
T object;
Node next;
}
}
Должен ли внутренний класс также реализовывать Serializable?