Results 1 to 4 of 4
  1. #1
    ShinTec's Avatar
    ShinTec is offline Member
    Join Date
    Jan 2010
    Posts
    51
    Rep Power
    0

    Default need help using equals methods

    hi forum

    I have a question reguarding the Object equals method .Can i use the equals method to verify that 2 arrays are the same. And if so how.

    If not what should i use instead. Just alittle confused about how to go about it :confused: .Any help would be much appreciated and thank you in advance.:D

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    You have to use the equals() method of Arrays class.

    When comes to the arrays you have to think about two things basically. One is the data type it can hold and the other one is the content.

    Consider the following code segment,

    Java Code:
    boolean[] ar1 = null; 
    boolean[] ar2 = null; 
    boolean b = Arrays.equals(ar1, ar2);
    What should be the value of b? It's true.

    What happen if the content are differ? Give a try first and let me know if you stuck on it.


  3. #3
    ShinTec's Avatar
    ShinTec is offline Member
    Join Date
    Jan 2010
    Posts
    51
    Rep Power
    0

    Default

    cheers i give it a try:o

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 8
    Last Post: 04-16-2012, 11:00 PM
  2. equals method :::::HELP:::::
    By alihht in forum New To Java
    Replies: 5
    Last Post: 03-09-2010, 07:19 AM
  3. == and equals()
    By arefeh in forum New To Java
    Replies: 13
    Last Post: 01-05-2010, 04:56 PM
  4. == is same as .equals()??
    By DrMath in forum New To Java
    Replies: 1
    Last Post: 09-30-2009, 04:57 AM
  5. Replies: 0
    Last Post: 01-25-2008, 11:13 PM

Posting Permissions

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