Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class OwnQueue {
- ArrayList<Object> list;
- public OwnQueue() {
- list = new ArrayList<Object>();
- }
- public boolean add(Object o) {
- return list.add(o);
- }
- public Object remove() {
- if (list.get(0) != null) {
- Object temp = list.get(0);
- list.remove(list.get(0));
- return temp;
- } else {
- System.out.println("Queue is empty");
- return null;
- }
- }
- public static void main(String[] args) {
- OwnQueue que = new OwnQueue();
- que.add("one");
- que.add("two");
- que.remove();
- System.out.println(que);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement