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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:12:52+00:00 2026-06-13T19:12:52+00:00

This is a pice of my code : ArrayList<String> Alist= new ArrayList<String>(); ArrayList<String> Blist=

  • 0

This is a pice of my code :

  ArrayList<String> Alist= new ArrayList<String>();
  ArrayList<String> Blist= new ArrayList<String>(); 

  Alist.add("gsm");
  Alist.add("tablet");
  Alist.add("pc");
  Alist.add("mouse");

  Blist.add("gsm");
  Blist.add("something");
  Blist.add("pc");
  Blist.add("something");

so i have two array list i want to compare all items and check if they are not equal and if they are to print out only the items that are not equal.

so i make something like this:

http://postimage.org/image/adxix2i13/
sorry for the image but i have somekind of bug when i post here a for looop.

and the result is :

not equals..:tablet
not equals..:pc
not equals..:mouse
not equals..:gsm
not equals..:tablet
not equals..:pc
not equals..:mouse
not equals..:gsm
not equals..:tablet
not equals..:pc
not equals..:mouse
not equals..:gsm
not equals..:tablet

i want to print only the 2 that are not equal in the example they are gsm and pc

not equals..:gsm
not equals..:pc
  • 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-13T19:12:54+00:00Added an answer on June 13, 2026 at 7:12 pm

    Don’t use != to compare strings. Use the equals method :

    if (! Blist.get(i).equals(Alist.get(j))
    

    But this wouldn’t probably fix your algorithmic problem (which isn’t clear at all).

    If what you want is know what items are the same at the same position, you could use a simple loop :

    int sizeOfTheShortestList = Math.min(Alist.size(), Blist.size());
    for (int i=0; i<sizeOfTheShortestList; i++) {
        if (Blist.get(i).equals(Alist.get(i))) {
            System.out.println("Equals..: " + Blist.get(i));
        }
    }
    

    If you want to get items that are in both lists, use

    for (int i = 0; i < Alist.size(); i++) {
        if (Blist.contains(Alist.get(i))) {
            System.out.println("Equals..: " + Alist.get(i));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have deploy.rb file with this pice of code: after :deploy do run if
Hello can someone help me with this pice of code. I have app with
This is my code: <CheckBox android:id=@+id/sprint_checkbox android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/sprint_game /> <CheckBox android:id=@+id/marathon_checkbox android:layout_width=fill_parent android:layout_height=wrap_content
I nave this pice of code in index.html (upload controller) This an example. <p>
This is my code: Stopwatch timer = new Stopwatch(); timer.Start(); while (timer.ElapsedMilliseconds < 3000)
This is my code to add sprites on Scene. for (int i = 3;
Ok, i wrote this pice of code as an beginner in java learning from
This is my code: OleDbConnection connection = new OleDbConnection( Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\Offline.accdb;Persist Security Info=False); connection.Open();
this is what i have so far: type u = {str : string} //some
I have an issue with Json response and accent characters. I have this pice

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.