New answers tagged

1

When having no clue on how to resolve such a problem it often helps to go through a couple of examples or use cases. Re-using those later as test cases helps to ensure everything works as intended. Try to keep the cases as small as possible but just big enough. When choosing them consider the corner cases of how things operate. E.g. let's take a capacity of ...


2

Here are a couple details from a quick glance at the code: If you are implemented a queue, consider actually implementing the Java Queue interface: FloatingQueue implements Queue Check you usage of booleans: if (isEmpty() == false) { ... } Is written in a more readable way as: if (!isEmpty()) { ... } Also, your isEmpty method is simply returning ...


3

Advice 1 In Java Collection Framework (the data structure framework residing in java.util.*), the item type is denoted by E, and not T. I suggest you do this: public class FloatingQueue<E> { ... E here and there. } Advice 2 FloatingQueue() { .... } You are clearly missing the public keyword here; without it, only the code in the same package ...


Top 50 recent answers are included