Ask your own question, for FREE!
Computer Science 24 Online
OpenStudy (anonymous):

will you please give me codes how to make a grocery line simulator in java?

OpenStudy (konradzuse):

??

OpenStudy (rsmith6559):

A line is a queue. A FIFO ( first in first out ) data structure. I'd bet that Java has a class for that, and javadoc has info about the class.

OpenStudy (anonymous):

I don't know what is available in Java but if you wanted to build your own instead of using a built in then there would be several options. If you know the maximum size of the queue, you could use an array and modular arithmetic to "move" the head of the line. You could also used a linked list type of structure for any size where you simply "push" (add) elements to the end of the list and "pop" remove elements from the start. These are a couple of options.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!