Results 1 to 4 of 4
  1. #1
    kesi is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Default using containsAll with ArrayList

    Is it possible to use containsAll() to compare items in an ArrayList?

    but it didn't make a whole lot of sense to me.


    Java Code:
        public boolean equals (SetInterface<T> set)
        {
    	if (store.containsAll(set))
    	    return true;
    	else 
    	    return false;
        }
    gives this error:
    javac SetInterface.java ASet.java TestASet.java
    ASet.java:50: containsAll(java.util.Collection<?>) in java.util.AbstractCollection<T> cannot be applied to (SetInterface<T>)
    if (store.containsAll(set))
    ^
    1 error

  2. #2
    kesi is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Default

    Sorry, I had a link above that I was unable to include since I am new to the forum and that's what I was referring to by "didn't make much sense to me"

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Your SetInterface would need to be a Collection for that to work.
    P.S Your method is rather odd. You are saying two collections are equal if one of them is a subset of the other.

Similar Threads

  1. Arraylist
    By gnarly hogie in forum New To Java
    Replies: 2
    Last Post: 12-11-2008, 01:59 AM
  2. Replies: 2
    Last Post: 04-21-2008, 11:43 AM
  3. ArrayList
    By ramitmehra123 in forum New To Java
    Replies: 1
    Last Post: 02-07-2008, 12:47 AM
  4. ArrayList
    By kizilbas1 in forum New To Java
    Replies: 1
    Last Post: 01-12-2008, 08:48 PM
  5. New to arraylist
    By kleave in forum New To Java
    Replies: 2
    Last Post: 11-19-2007, 06:45 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
  •