Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7913271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:48:09+00:00 2026-06-03T13:48:09+00:00

I quickly wrote a linked list class in Java. I want to write another

  • 0

I quickly wrote a linked list class in Java. I want to write another queue class which uses the linked list. How would I achieve this in Java? I don’t fully understand the implements / extends keywords… this is what my queue looks like ( for example):

public class Queue<T> implements LinkedList
{
    protected LinkedList<T> list;

    public Queue() {
        list = new LinkedList<T>();
    }

    public void add( T element) {
        list.add( element);
    }

    public T removeLast() {
        return list.removeLast();
    }   
}

Also note that the linked list class is also generic.
I know there are already built in classes to achieve this functionality, but I wanted to learn ( which is why I am trying to do this manually)

EDIT: Additionally, in the end, I would like to be able to say something like this:

Queue<String> aQueue = new LinkedList<String>();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:48:11+00:00Added an answer on June 3, 2026 at 1:48 pm

    If you want a behavior like Queue<String> aQueue = new LinkedList<String>(); then your LinkedList must extend/implement the Queue class/interface. Remember that a super class can be the object reference instance of a sub class, not viceversa.

    public class LinkedList<T> implements Queue<T> {
    
        class Node<T> {
            T data;
            Node<T> next;
        }
    
        //all your behavior here
    }
    

    Also, as the Java documentation states, Queue is an interface and LinkedList implements it.

    Note: If you want to implement a Queue using your LinkedList, you should see the code sample posted by @Tudor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is very similar to another question ( Functional Data Structures in Java )
I wrote this quickly under interview conditions, I wanted to post it to the
I have a Java desktop application I wrote, and I would like a recommendation
I quickly wrote this up, http://www.ionfish.org/php-shrink/ where a user uploads a .php file with
Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote
I wrote this to quickly test Why arent my settings being saved? The first
I wrote this up quickly because I am having problems with it. I apologize
I wrote a stock market simulator which uses a ConcurrentHashMap as a cache. The
I quickly wrote an interpreter for some sort of experimental programing language i came
I'm trying to write a short function that will let me quickly read in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.