Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: error in HashSet

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default error in HashSet

    Hi,

    I have a small program here where in im learning to use HashMap.
    import java.util.HashSet;
    import java.util.Set;
     
    public class test {
     
            public static void main(String[] args) {
                    Set set = new HashSet();
                    set.add("pooja");
                    if(set.contains("pooja")) {
                            System.out.println("contains"); }
                    else {
                            System.out.println("does not contain"); }
            }
    }
    But when i try to run this, it gives me an error saying
    "Note: test.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details."

    Can anyone tell me what does this error mean ? and what do i do to make this program run ??

    Thank you in advance ..


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: error in HashSet

    For what its worth its a warning and not an error. The collection you are using is not specified to hold any particular class...see Lesson: Generics (The Java™ Tutorials > Learning the Java Language)

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/41834-error-hashset.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    http://www.javaprogrammingforums.com...s-posting.html

    Last edited by copeg; April 4th, 2011 at 09:23 AM.

Similar Threads

  1. Removing objects from a hashSet
    By JohnTor in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 4th, 2010, 03:03 PM