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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:55:15+00:00 2026-06-11T14:55:15+00:00

Im having trouble in my main class here and I’m trying to add new

  • 0

Im having trouble in my main class here and I’m trying to add new item, remove , find and display in my list, and I have tried everything with a scanner and it seems to not work..this is my code so far and what I have done…how would I be able to do it ?

  import java.util.*;
  import java.util.LinkedList;

    public class Main {
public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    SinglyLinkedList<String> names = new SinglyLinkedList<String>();
    names.add("Fred");
    names.add("Earl");
    names.add("Dan");
    names.add("Carl");
    names.add("Ben");

    System.out.println(names);



    System.out.println("Add an item");
    System.out.println("" + input.nextLine());
    names.add();
    System.out.println("LinkedList:" + names);

    System.out.println("Remove an item");
    System.out.println("" + input.nextLine());
    names.remove();
    System.out.println("LinkedList:" + names);


    System.out.println("Find an item");
    System.out.println("" + input.nextLine());
    names.findFirst(element);
    System.out.println("LinkedList:" + names);


    System.out.println("Display an list");
    System.out.println("LinkedList:" + names);

    System.out.println("Exit");
    input.close();


}

 }
  • 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-11T14:55:16+00:00Added an answer on June 11, 2026 at 2:55 pm

    You’re not actually adding or removing anything to your LinkedList because you never pass any arguments to the add and remove methods. Try something like this:

    System.out.println("Add an item");
    names.add(input.nextLine());
    System.out.println("LinkedList: " + names);
    
    System.out.println("Remove an item");
    names.remove(input.nextLine());
    System.out.println("LinkedList: " + names);
    
    
    System.out.println("Find an item");
    names.findFirst(input.nextLine());
    System.out.println("LinkedList: " + names);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble trying to handle a signal... I have a multithreaded application,
I am having trouble with deep-copying a list. My main window, called Form1 ,
I'm having some trouble understanding this. Here's what's happening. I'm spawning a new thread
Here is a part of my code I'm having trouble with: ===Class Overload=== public
I am quite new to linux development, and having trouble using a class from
I am having trouble passing the return value from TheMethod() to Main and displaying
Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder
I'm trying to use a ThreadPool implementation from this fellow: https://github.com/progschj/ThreadPool I'm having trouble
I'm creating a queue class in c++ and am having trouble getting the front
I must be missing something here, but I seem to be having some trouble

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.