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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:13:53+00:00 2026-06-14T20:13:53+00:00

I have a problem with the contains() method which returns false even though the

  • 0

I have a problem with the contains() method which returns false even though the ArrayList contains the given Object.
My code is following:

String [] transaction = dbConnection.getPendingTransaction(username);
if (!onlineConnection.getSentTransactionRequests().contains(transaction)) {
    onlineConnection.getSentTransactionRequests().add(transaction);

    String packet = "RTR" + "_" + transaction[0] + "_" + transaction[2] + 
                        "_" + transaction[3] + "_" + transaction[4];
    onlineConnection.send(packet);
}

I have tried Thread.sleep() between iterations, so the ArrayList wasn’t load as eagerly without success.

  • 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-14T20:13:54+00:00Added an answer on June 14, 2026 at 8:13 pm

    The hashCode() and equals() of arrays are a bit broken when it comes to this (it is a long different discussion why).

    A possible work around is to use ArrayList<ArrayList<String>> instead of ArrayList<String[]>, the equals() method for ArrayList will be as you expect it to.

    For example:

        ArrayList<String> l1 = new ArrayList<>();
        ArrayList<String> l2 = new ArrayList<>();
        l1.add("asdf");
        l2.add("asdf");
        ArrayList<ArrayList<String>> coll = new ArrayList<>();
        coll.add(l1);
        System.out.println(coll.contains(l2));
    

    Will yield true, as expected

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

Sidebar

Related Questions

Is there any solution to overcome case-sensitive problem for contains method. I have code
I have problem with SQL query. If given order contains items, witch does not
I have a problem parsing a XML file which contains special characters like ,
I have a problem finding elements in XPath that's contains a certain string ignoring
I have the problem running executable .jar file. I've created a project which contains
I have a problem with a keystore in pkcs12 format, which contains a private
I have some problem with Android AsyncTask. There is an Activity which contains some
I have a method from which i am returning object like public static Object
Given an object A, which contains a callable object B, is there a way
I have a problem with a search query I am using my data contains

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.