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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:13:51+00:00 2026-06-01T19:13:51+00:00

this is my SSCCE http://pastebin.com/rABzKgAx http://pastebin.com/SypQxApe Im trying to work with datastructure List of

  • 0

this is my SSCCE

http://pastebin.com/rABzKgAx

http://pastebin.com/SypQxApe

Im trying to work with datastructure List of Deque of Integer.

So i add few integers to the deque, then add it to the finalList, but since i manipulate further with Deque and remove elements it also removes these elements from the finalList. So how am i supposed to save these items to the list ? Becuase for example, i add 30 elements to the finalList, but since i am removing the original item from Deque i simply have 30 empty elements in finalList:/. You can read the rest from the code, and on the line 57 there is a output on stdout, ant it returns empty string, so there you can see the problem.

So the problem is that i copy only reference to the object, not the object, so how am i supposed to copy object ?

  • 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-01T19:13:53+00:00Added an answer on June 1, 2026 at 7:13 pm

    This is where using a debugger is helpful.

    You are using

    finalList.add(tokens);
    

    and assuming you have added a copy of the list, but you are only adding a copy of the reference to the list.

    So

                tokens.add(token);
                Func(places, index+1, tokens);
                tokens.removeLast();
    

    removes every element it adds, and the list is empty.

    It appears what you intended was

            finalList.add(new LinkedList<Integer>(tokens));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked this before, but only theoretically, without an SSCCE. Now, I've created one,
I'm trying to experiment with the non- JTextArea Swing text components, and in this
I've tried: table.getTableHeader().setBackground(Color.BLACK); Doesn't work. EDIT: This code doesn't work in my project only.
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today
This might seem like a stupid question I admit. But I'm in a small
This is a difficult and open-ended question I know, but I thought I'd throw
This is my first post here and I wanted to get some input from
This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit

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.