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 8604883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:41:12+00:00 2026-06-12T02:41:12+00:00

First of all, i have been studying Java for only the last couple of

  • 0

First of all, i have been studying Java for only the last couple of weeks, so I don’t have much experience yet.

This is more of a theoretical question.
I want to create a simple list.

So first I made a class where I specified some methods. I want it to be generic so I can use any type.

  public interface List<E> 

Now i need to implement it, so i created:

    public class MyList<E> implements List<E>

Now, I need two attributes:

 private E element;
 private MyList<E> next;

One will hold my generic type, the other will be the link to the next element.
First of all, I don’t know if it’s the correct way to write it. And if i leave this attributes inside this class, will it work properly?

Second of all, I have been thinking whether it’s better to create another class, lets say a Box class, that will contain these two fields, thus making manipulation easier during my implementation.

Might be a silly question, but I am trying to learn and to understand the best ways to do this.

Thanks for your time.

  • 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-12T02:41:13+00:00Added an answer on June 12, 2026 at 2:41 am

    I guess you are trying to implement a singly-linked list. Now to answer your question, I think that it would be beneficial for you to create a Box class like you mentioned (often called Node). So your implementation might look like this:

    public class MyList<E> implements List<E> {
        private Node<E> head;
    
        private static class Node<E> {
            private E element;
            private Node<E> next;
    
            public Node(E element, Node<E> next) {
                this.element = element;
                this.next = next;
            }
    
            // ...
        }
    
        // ...
    }
    

    MyList would hold a single Node that is connected to a chain of other Nodes. If you take a look, this is how the the actual java.util.LinkedList class is written.

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

Sidebar

Related Questions

I have been studding GIT for the last couple of weeks in an attempt
First of all i am brand new to Java : / I have been
First of all this is homework. I have been trying to get rid of
I have been experimenting some problems with the fully distributed version. First of all
First of all I have many Django instances setup and running like this. In
First of all I have searched many times in this forum but none is
First of all i have to clear few things 1.This is not spam group
Hi guys first of all I have no expirience with DB programing only basic
I have been studying (old) 3D rendering techniques for the past weeks and think
I have been all over this one, and I am just plumb stuck. I

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.