Challenge: Generics

Try your newly acquired skills on generics to implement a generic method.

We'll cover the following

Problem Statement

Add a method firstItem(List<T> items) which takes a list of items and returns the first item. This method should return the first item of the two lists of different data types.

List #1:

List<double> itemsDoubles = List<double>.from([1.0, 2.0, 3.0, 4.0, 5.0]);

List #2:

List<String> itemsString = List<String>.from(["Grace", "Ana", "Diana", "Sima", "Patricia"]);

Get hands-on with 1400+ tech skills courses.