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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:04:06+00:00 2026-05-26T04:04:06+00:00

I have a linkedList using nodes. I have it printing out alphabetically but now

  • 0

I have a linkedList using nodes. I have it printing out alphabetically but now I’m trying to print out the people whose names begin with a certain letter that the user ask for. For example: printing out all the people whose names begin with an “A”. I’m sure this isn’t the best way to do this what I have so far but I’m just trying different things out and I’m pretty new to linked list. Any tips or advice or hints are greatly appreciated.

Heres what I think I have that may be useable:

       public void findSameStartingLetter(BigNode front, String letter) {
       BigNode curr;
       curr = front; 
       String name;
       name = curr.dataitems;
       String d;
    //   char c; 
          while (curr.next != null){

              d = name.substring(0, 1);
            if (d.equals(letter)) {
                System.out.println(d);
              curr = curr.next;

         // for(int i=0; i < 1; i++) { 
              //  c = letter.charAt(i);
        //  }
              } 

          }
   }
  • 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-26T04:04:07+00:00Added an answer on May 26, 2026 at 4:04 am

    It looks like you need to be reading the name of the person on the node within the loop, rather than reading in the first name and then not assigning that variable again.

    You also should be checking to see if the current node is null, not the next one. If you check for the next one, you will miss the last name in the list.

    Also, make sure the pointer movement on the list is done outside the if, as we want to check the next node regardless of what the name was.

    Aside from the logic, it looks like you are a little uncomfortable with java. To clean up your example you can use the java ability to delare and assign values on one line.

    Futhermore, rather than doing a substring and comparing the substring, Java’s string has a startWith method that should do the trick as well. Nice job!

    public void findSameStartingLetter( BigNode front, String letter )
        {
            BigNode curr = front;
            while( curr != null )
            {
                String name = curr.dataitems;
                if( name.startsWith( letter ) )
                {
                    System.out.println( name );
                }
                curr = curr.next;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using scala I have added about 100000 nodes to a linked list. When I
I have a LinkedList, where Entry has a member called id. I want to
I have two LinkedList objects that are always of the same size. I want
If I have an LinkedList of Employee objects... Each employee has a Name, and
I have implemented a linked list as a self-referencing database table: CREATE TABLE LinkedList(
Say you have a linked list structure in Java. It's made up of Nodes:
I have to implement a one linked list but it should put object in
I've been trying to figure out how to reverse the order of a doubly-linked
I'm working on a program using doubly linked lists. I have already gotten the
I have been trying to implement my own linked list class for didactic purposes.

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.