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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:16:33+00:00 2026-06-05T18:16:33+00:00

public void printList( ){ Node<E> p ; System.out.printf( [ ) ; for ( p=head.next

  • 0
public void printList( ){
    Node<E> p ;
    System.out.printf( ” [ ” ) ;
    for ( p=head.next ; p != null ; p=p.next )
        System.out.print( p.element ) ;
    System.out.printf( ” ] ” ) ;
}

public void addLast (E e){
    Node<E> p = head;   // <--- data type Node<E>, var name = p, but what is head type?
    while ( p.next != null )
        p = p.next ;
    p.next = new Node<E>(e , null ) ;
}

Generics Example:

public class Box {
private Object object;

public void set(Object object) { this.object = object; }
public Object get() { return object; }

}

Using Generics:

// T stands for "Type"
public class Box<T> {
    private T t; 

    public void set(T t) { 
        this.t = t;
    }
    public T get() { 
        return t;
    }
}

I have a general idea of how linked list work intuitively however I can’t see it in code.

I know you have the element and a reference to the next node. In the code above, how does the “.” operator work as it traverses through the list until null is reached?

I believe ‘next’ is a reference variable. when it does p=p.next, how does it work in code/computer?

On a unrelated note, node ? instead of node(E)? difference? In the example above, it seems ‘object’ was replaced by ‘t’, i can’t see the advantage. ;S

Any help is really appreciated, thanks in advance!

  • 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-05T18:16:36+00:00Added an answer on June 5, 2026 at 6:16 pm

    It might help to think of a LinkedList as a List of linked Nodes. Where each Node will hold a reference to the next Node (if one exists). I’m not sure if it will help, but when I had to do this assignment in School I found that looking through the API and trying to use it very helpful.

    With Generics Node will be a Node of type Object Where Node will be a Node of a specific type. For example, LinkedList will hold Strings. This, might help to get a better understanding of how generics work.

    Here is a simple example of using generics:

    Class Box<E>{
        private E variable;
    
        public E get(){
            return variable;
        }
    
        public void set(E variable){
            this.variable=variable;
        }
    
        public static void main(String[] args){
            Box<String> example=new Box<String>();
            example.set("test");
            System.out.println(example.get());
    
            Box<Integer> example2=new Box<Integer>();
            example2.set(1);
            //example2.set("test");will not work because it is types as an Integer
            System.out.println(example2.get()+1);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import javax.swing.JOptionPane; public class RotateArrayCircularLL { private Node head=null; public void init() { int
public abstract class Master { public void printForAllMethodsInSubClass() { System.out.println (Printing before subclass method
public void setIntersection(LinkList list1, LinkList list2) { LinkList list4 = new LinkList(); Node a
template <typename T> class LinkedNode { public: T data; LinkedNode<T> *next; LinkedNode<T> *prev; LinkedNode<T>();
public void MyTest() { bool eventFinished = false; myEventRaiser.OnEvent += delegate { doStuff(); eventFinished
public void CardToPile() { waste.push(reserve.pop); }
public void Save() { XmlSerializer Serializer = new XmlSerializer(typeof(DatabaseInformation)); /* A first chance exception
public void EatDinner(string appetizer, string mainCourse, string dessert) { try { // Code }
public void DoPing(object state) { string host = state as string; m_lastPingResult = false;
public void openReport() { try { HashMap params = new HashMap(); params.put(aapor, 19); JasperReport

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.