A sequence is similar to a bag in the sense that both are co
A sequence is similar to a bag in the sense that both are collection data types, however, unlike a bag, the elements in a sequence are arranged one after another.
Using the generic linked list discussed in the class/book, implement a generic sequence data type named GenericLinkedSeq to represent a sequence of elements of generic type E.
Solution
public class GenericLikedSequence // generic method printArray public static < E > void printArray( E[] inputArray ) { // Display array elements for(E element : inputArray) { System.out.printf(\"%s \", element); } System.out.println(); } public static void main(String args[]) { // Create arrays of Integer, Double and Character Integer[] intArray = { 1, 2, 3, 4, 5 }; Double[] doubleArray = { 1.1, 2.2, 3.3, 4.4 }; Character[] charArray = { \'H\', \'E\', \'L\', \'L\', \'O\' }; System.out.println(\"Array integerArray contains:\"); printArray(intArray); // pass an Integer array System.out.println(\"\ Array doubleArray contains:\"); printArray(doubleArray); // pass a Double array System.out.println(\"\ Array characterArray contains:\"); printArray(charArray); // pass a Character array } }