Results 1 to 2 of 2
  1. #1
    raj reddy is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default count variable is not incrementing for the last comparison of the arrays

    Hi








    Requirement : count variable should increment upto the last comparison of the arrays.

    ie count=1,2,3,4,5....upto last comparison of the arrays like that


    and also count variable should be increased if and only if the two arrays values are equal

    everything is fine but only the count variable is not incrementing for the last comparison of the arrays

    Let us think that there are two arrays al1 and al2;




    MY CODE:

    al1={1,2,3}


    al2=(1,2,3,4,5,6,7,8,9}



    int count=0;


    for (int i=0;i<al1.size();i++) {
    {

    for (int j=0;j<al2.size(); j++) {



    if(al1.get(i).equals(al2.get(j)))

    count++;


    }


    Actually the count variable should increment for every comparison of the al1 and al2.


    MY PROBLEM IS : THe variable is incrementing fine for every comparison , but for the last comparison of the arrays the count variable is not incrementing.


    can u validate the count variable such a way that i have to get the last comparison value of the two arrays.

  2. #2
    orchid's Avatar
    orchid is offline Member
    Join Date
    Apr 2007
    Location
    Midwest
    Posts
    60
    Rep Power
    0

    Default

    I tried looking at this but you are missing the instantiation of al1 and al2. Can you please add more code so I can at least copy this and have it compile?
    Would be glad to help you if you put in the enough code so that I can compile it. I do not want to guess what type of object al1 and al2 are.
    thx

Similar Threads

  1. String comparison
    By abhiN in forum New To Java
    Replies: 2
    Last Post: 04-09-2008, 05:47 AM
  2. Comparison of Strings
    By Cero.Uno in forum New To Java
    Replies: 3
    Last Post: 02-11-2008, 03:46 AM
  3. Date comparison
    By Rageagainst20 in forum New To Java
    Replies: 0
    Last Post: 12-19-2007, 07:34 PM
  4. Parsing Dates for Comparison
    By Rageagainst20 in forum New To Java
    Replies: 1
    Last Post: 12-19-2007, 06:50 AM
  5. String comparison
    By sireesha in forum New To Java
    Replies: 1
    Last Post: 12-18-2007, 01:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •