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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:34:33+00:00 2026-05-20T10:34:33+00:00

This is not something which I would do in real life, but say: LinkedList

  • 0

This is not something which I would do in real life, but say:

LinkedList = a,b,c,d,e and I get their corresponding index.

Say, I want to remove b (index=1) and d (index=3)(i.e. values surrounding c (index=j=2))

Now,I do (which works fine):

When j=2
LS.remove(j + 1); ----> j=3 (d removed)
LS.remove(j - 1); ----> j=1 (b removed)

And b and d are removed.

But if, I do (does not work):

When j=2
LS.remove(j - 1); ----> j=1 (b removed)
LS.remove(j); ----> j=2 (d is not removed) (used j because due to above removal, LL has adjusted it self)

i.e. when I move the value preceding ‘c’ first, ‘d’ is not removed and the LL stays as it is. I guess, I am doing the same thing.

Am I missing out on something here?

UPDATE:

So, when I change the signature public void operation(String operator, Integer j) to public void operation(String operator, int j), it worked.

  • 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-20T10:34:34+00:00Added an answer on May 20, 2026 at 10:34 am

    If j is of type big Integer, then LinkedList.remove(Object) will be called instead of LinkedList.remove(int). And that’s not what you actually want.

    I don’t see any reason to use big-Integer as the type of j in your second example, you should use primitive int.

    Please check Why aren't Java Collections remove methods generic? on why LinkedList still has remove(Object) signature.

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

Sidebar

Related Questions

I want to know i can do something similar to this (not working) code
Am I not seeing something obvious here, can't seem to get this to work...
I'm trying something like this, but this example does not work. jsObj = {};
Not sure if I've just missed something but this doesn't work: $(this).children('td.threadtitle a').html('thread title');
I am not sure why this is not working. Perhaps I am missing something
Does .NET Transliteration library exists ? Note that this is not translation, something like
So this is something that I have not been able to find any documentation
I have not had to do something like this in the past and am
Now I'm not sure if this is something I'm doing wrong, or something thats
This is my first azure project and I'm not sure if I'm doing something

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.