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

  • Home
  • SEARCH
  • 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 4058164
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:02:42+00:00 2026-05-20T15:02:42+00:00

Since there are no self-refering pointer concept in Java… How do I proceed to

  • 0

Since there are no self-refering pointer concept in Java… How do I proceed to tackle this issue…

I am not allowed to use Built in class of Link List in Java…

But “Should follow the same method of creation of Link List like in C.” What could be the best Substitute node->next, node->prev in Java…

  • 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-05-20T15:02:42+00:00Added an answer on May 20, 2026 at 3:02 pm

    Instead of an object with a pointer to the next node and an var, in java linked lists can be implemented by making a class with a member variable of itself.

    a sample implementation is listed below:

     1    public class Node
     2  {
     3      private int myInt;
     4      private Node nextNode;
     5     
     6      public Node(int val)
     7      {
     8          myInt = val;
     9          nextNode = null;
    10          return this;
    11      }
    12  
    13      public int getMyInt()
    14      {
    19          return myInt;
    20      }
    21  
    22      public Node(Node prev, int val)
    23      {
    24          prev.nextNode = this;
    25          myInt = val;
    26          nextNode = null;
    27      }
    28  
    29      public void addNode(Node newNode)
    30      {
    31          nextNode = newNode;
    32      }
    33  
    34      public void printNodes()
    35      {
    36          System.out.println(myInt);
    37          if (nextNode != null)
    38          {
    39              nextNode.printNodes();
    40          }
    41      }
    42  
    43      public void printNode()
    44      {
    45          System.out.println(myInt);
    46      }
    47
    48      public Node nextNode()
    49      {
    50          return this.nextNode;
    51      }
    52  }
    

    To create a link list, create head:

    Node head = new Node(1);
    

    This node class has two ways of adding nodes to the list:

    Node secondNode = new Node(head, 2);
    

    or

    head.addNode(new Node(2))
    

    here is an example of a list with values 1 – 10

    Node head = new Node(1);
    Node tempPtr = head;
    
    while ( tempPtr.getMyInt() <= 10 )
    {
        tempPtr.addNode(new Node(tempPtr.getMyInt()+1));
        tempPtr = tempPtr.nextNode();
    }
    

    now you can print access the elements of this list by iterating through the list.

    tempPtr = head;
    while ( tempPtr != Null )
    {
        tempPtr.printNode()
        tempPtr = tempPtr.nextNode()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since there is no finally in C++ you have to use the RAII design
Since there is a large pool of passionate developers in this community, I would
Since there is no concept of sessions in ASP.Net MVC and each request is
I know there is a WeakHashMap in java.util , but since it uses WeakReference
I've read a few posts on this, but there's still one thing that's not
Since there is apparently no Flash control that can accept bitmap pastes , I
Since XAML gets compiled, there should be no difference in execution of code like
Since I've gotten no answer at all to my question Is there an alternative
Since Object Initializers are very similar to JSON, and now there are Anonymous Types
Since Indy is now built-into the install process of Delphi 2009... is there a

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.