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

  • Home
  • SEARCH
  • 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 8615831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:28:37+00:00 2026-06-12T05:28:37+00:00

public void returnRental(Customer cust){ Rental toDelete = null; //Rental to be removed from list.

  • 0
public void returnRental(Customer cust){
    Rental toDelete = null; //Rental to be removed from list.
    LinkedList<Video> toReturn = null; //List of videos to be added to inventory.

    //Find appropriate rental according to customer name. 
    for(int i = 0; i < rentals.size(); i++){
        if(cust.getName() == rentals.get(i).getRentee().getName()){
            toReturn = rentals.get(i).getRented();
            toDelete = rentals.get(i);
        }
    }

here is the snippet of code that is giving me problems. I’ve debugged it in eclipse quite a bit which ended up just confusing me more. It hits the if, and passes the condition. But once it gets to assigning values to “toReturn” it assigns it an empty list with size 0. Where as I check my rentals Linked list and the correct value are there, but for some reason it is not getting assigned to my variables correctly 🙁 The same happens to “toDelete” but this isn’t a list, it is one instance of my class Rental. (The linked list is a list of rentals, which contains a linked list of videos)

No errors are thrown…
Its a little difficult to explain, if you need more information please let me know and i’ll clarify.

I’m at a loss, possibly because I’m not iterating through my linked list correctly?

  • 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-12T05:28:38+00:00Added an answer on June 12, 2026 at 5:28 am

    I’ve upvoted dystroy’s answer because incorrect string comparison is always wrong.

    But because that would fail differently (customer names not matching rentee names), I’m wondering if your issue is really caused by either of the following:

    1. a problem in getRented(); or
    2. cust having a null name on call, which would match a Rentee with a null name.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public void wahey(List<Object> list) {} wahey(new LinkedList<Number>()); The call to the method will not
public void DoRiskyThings(List<Action> tasks) { List<Exception> exceptions = new List<Exception>(); foreach(Action task in tasks)
public void testNullsInName() { fail(sample failure); Person p = new Person(null, lastName); assertEquals(lastName, p.getFullName());
public void ExecStoredProc(string strprocName, SqlConnection sqlConnect, List<string> Paramvalues) { if (ConnectToDB() == true) {
public void test() { List<int> list = new List<int>(); list.Add(1); list.Add(2); list.Add(3); for (int
public void Insert(int value) { if (value < Data) { if (LeftNode == null)
public void Foo (IEnumerable<object> objects) { } var strings = new List<string>{first, second, third};
public void processloader(object temp) { Process[] processes = null; try { processes = Process.GetProcesses();
public void findClassNodesMatching(String lowerCaseSearchText, List<? extends DefaultMutableTreeNode> foundNodes) { findClassNodesMatching(lowerCaseSearchText, (DefaultMutableTreeNode) getRoot(), foundNodes); }
public void sort() { datelist = new List<DateTime>(rdate); //timedates intlist = new List <Int>(rint);

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.