Will
unread,Nov 29, 2010, 10:37:55 PM11/29/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Cornell CS 2110
I found it useful to create a queue data structure that stores a fixed
number of elements and automatically removes the oldest element when
you try to add a new element. I'm just using a basic array to store
the elements.
However, apparently in Java you can't create an array of generics, so
trying the code
T[] elements = new T[maxSize];
gives an error.
I can get around this by doing T[] elements = (T[]) new
Object[maxSize];
However, I then get a warning from Eclipse about unchecked casting. Is
it ok to just ignore this error and add a
@SuppressWarnings("unchecked")
at the top of the class definition, or is this a bad idea?