Presentation is loading. Please wait.

Presentation is loading. Please wait.

8-2.

Similar presentations


Presentation on theme: "8-2."— Presentation transcript:

1 8-2

2

3 Class removeFromFront();

4

5

6

7

8

9 Class

10 Class

11 Generics in Java Using the Object class as the data type in a linked list’s Node allows the list to contain any data type, but it also allows having lists with nodes of heterogeneous types, which is usually undesirable. To create a generic list class that allows the list to contain any data type, but does not allow heterogeneous data types in a list, we can use a new feature in Java called the Generics. The feature of Generics in Java allows applications to create classes and objects that can operate on any defined types.

12 The Generic List Class Node<T> nextNode; Node<T> getNext()
Node<T> node)

13 The Generic List Class

14 The Generic List Class

15 Instantiating Lists of Different Types
List <Student> studentsList = new List<Student>(“CSC 113”); List <Integer>intList= new List<Integer>(“integer List”); List<String> nameList= new List<String> (“names list”); ….


Download ppt "8-2."

Similar presentations


Ads by Google