[Solved] Java Generics Question


That ‘terminated’ you have been seeing lately is the expected behavior when your program finishes.

Put some System.outs or asserts to verify that your code runs (here it runs, with some awful cast warnings, but runs)

final Queue12<T> ringBuffer = new QueueImpl12<T>();
T o = (T) new String("this");
ringBuffer.enqueue(o); //add element to the back
System.out.println(ringBuffer.peek());//this should print 'this' in the console\
//assertEquals('this', ringBuffer.peek());
ringBuffer.dequeue();  //remove/return element in the front

Learn how to use generics and tests. And don’t put generic argument in main function, is is useless there.

solved Java Generics Question