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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:19:11+00:00 2026-06-19T03:19:11+00:00

I’m looking to use a method that takes in the information of an object,

  • 0

I’m looking to use a method that takes in the information of an object, creates an instance of the object, sets the information, then it creates a node and sets the information to the node, and finally inserts the node into my linked list where it belongs. The linked list only has to be organized by the rfidTag String type which is a 9-digit hexadecimal representation. Here is what I have so far (I’ve ignored the “by rfidTag” part)…

public class ItemList {

    ItemInfoNode head;
    ItemInfoNode tail;
    ItemInfoNode cursor;

    int listCount = 0;

    public ItemList(){
        head = cursor = tail = null;
    }

    public void insertInfo(String name, String rfidTag, String initPosition,
            double price) {
        ItemInfo obj = new ItemInfo(name, rfidTag, initPosition, initPosition, price);
        ItemInfoNode temp = new ItemInfoNode();
        temp.setInfo(obj);
    }
}

Now I don’t have the slightest clue as to what to put, but I’ll show you what I’ve tried and add comments as to where I am lost and looking to accomplish…

ItemInfo obj = new ItemInfo(name, rfidTag, initPosition, initPosition, price);
ItemInfoNode temp = new ItemInfoNode();
temp.setInfo(obj);

if (head == null) {
    head = temp;
    cursor = temp;
    tail = temp;
    head.setNext(cursor);
    tail.setPrev(cursor);
    listCount++;
} else {
    cursor = temp;
    cursor.setPrev(head);
    cursor.setNext(tail);

    System.out.println(cursor.getPrev().getInfo().getName());
    System.out.println(cursor.getInfo().getName());
    System.out.println(cursor.getNext().getInfo().getName());
    // Now I stop here because I do not understand how to put a 3rd in
    // between my head and tail without losing the middle nodes info (cursor)
    // These printlns are here to help me understand what exactly is happening!
    // So I am rather unclear one what my next step should be
}

I AM CURRENTLY TRYING TO GET MY OTHER ATTEMPTS TO RUN WITHOUT THROWING EXCEPTIONS! WILL ADD WHEN FINISHED!

  • 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-19T03:19:13+00:00Added an answer on June 19, 2026 at 3:19 am

    Assuming that cursor points to the node after which the node is to be inserted.

    ItemInfo obj = new ItemInfo(name, rfidTag, initPosition, initPosition, price);
    ItemInfoNode temp = new ItemInfoNode();
    temp.setInfo(obj);
    
    if(head == null){
      head = tail = cursor = tmp;
    }
    
    else{
      if(cursor == tail)
      {
        cursor.setNext(tmp);
        tmp.setPrev(cursor);
        tail = tmp;
      }
      else
      {
        tmp.setNext(cursor.getNext());
        tmp.setPrev(cursor);
    
        cursor.getNext().setPrev(tmp);
        cursor.setNext(tmp);
      }
    }
    
    listCount++;
    

    With this, if the node is inserted for the first time then All (head, tail and cursor) will point to the first node. If n number of nodes are already present then we need to insert the new node according to the position of the cursor. If cursor points to the tail, then the new node is added at the end and tail is updated. If cursor points to any other node (including head) then the new node is inserted after the cursor and tail is untouched. In both the cases the head is untouched i.e., head will always point to the first node. [Tail will always point to the last node — and updated accordingly]

    Hope this helps!!

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am confused How to use looping for Json response Array in another Array.
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.