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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:34:26+00:00 2026-05-26T03:34:26+00:00

I created a basic node linked list that displays the size of the list

  • 0

I created a basic node linked list that displays the size of the list in number (ie: 0 – 9 )
Now I’m trying to alter what i have to display a list of names. I’m confused on what I need to change and what is going to be different. The names are going to be in string format. Eventually I’m going to read in a list of names from a txt file. For now I’m using just 3 names and test data.

       import java.util.*;

  public class Node {
public int dataitems; 
public Node next; 
Node front;

public void initList(){
    front = null;
}

public Node makeNode(int number){
    Node newNode;
    newNode = new Node();
    newNode.dataitems = number;
    newNode.next = null;
    return newNode;
}

public boolean isListEmpty(Node front){
    boolean balance;
    if (front == null){
        balance = true;
    }
    else {
        balance = false;
    }
    return balance;

}

public Node findTail(Node front) {
    Node current;
    current = front;
    while(current.next != null){
        //System.out.print(current.dataitems);
        current = current.next;

    } //System.out.println(current.dataitems);
    return current;
}

public void addNode(Node front ,int number){
    Node tail;
    if(isListEmpty(front)){
        this.front = makeNode(number);
    } 
    else {
        tail = findTail(front);
        tail.next = makeNode(number);
    }
}

public void printNodes(int len){

    int j;
    for (j = 0; j < len; j++){
        addNode(front, j);
    }  showList(front);
}

public void showList(Node front){
    Node current;
    current = front;
    while ( current.next != null){
        System.out.print(current.dataitems + " ");
        current = current.next;
    }
    System.out.println(current.dataitems);
}


public static void main(String[] args) {
     String[] names = {"Billy Joe", "Sally Hill", "Mike Tolly"}; // Trying to print theses names..Possibly in alphabetical order

    Node x = new Node();
     Scanner in = new Scanner(System.in);
        System.out.println("What size list? Enter Number: ");
    int number = in.nextInt();
     x.printNodes(number);
    } 

}

  • 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-26T03:34:26+00:00Added an answer on May 26, 2026 at 3:34 am

    several things must be changed in my opinion

     public void printNodes(String[] nameList){
    
        int j;
        for (j = 0; j < nameList.length; j++){
            addNode(front, nameList[j]);
        }  showList(front);
    }
    

    you have to pass the array containing the names

    x.printNodes(names);
    

    also change:

    public void addNode(Node front ,String name){
        Node tail;
        if(isListEmpty(front)){
            this.front = makeNode(name);
        } 
        else {
            tail = findTail(front);
            tail.next = makeNode(name);
        }
    }
    

    and :

    public Node makeNode(String name){
        Node newNode;
        newNode = new Node();
        newNode.dataitems = name;
        newNode.next = null;
        return newNode;
    }
    

    and don’t forget to change the type of dateitem into string :

          import java.util.*;
    
      public class Node {
    public String dataitems;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a basic WCF service in IIS. I am aware that this
I've created a basic orthographic shader that displays sprites from textures. It works great.
I have created a basic site using ASP.NET routing according to Mike Ormond's example
I have created a pretty basic Flash website for a client and am having
I created a basic XmlDocument with one node: XmlDocument bigDoc = new XmlDocument(); bigDoc.LoadXml(<Request></Request>);
I created a basic TCP server that reads incoming binary data in protocol buffer
I'm running a basic Express app in Node.js and trying to deploy to Heroku.
I'm trying to create a basic Node application, every time a client connects I
I've created this basic 3D Demo using OpenGL/SDL. I handled the keyboard callback so
I created just the most basic WCF Service Application to do some prototyping, but

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.