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 3 of 3

Thread: problem in crearting a Set object(Set here refers to java.util.Set)

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default problem in crearting a Set object(Set here refers to java.util.Set)

    //My code is showing a problem please help me find the the error::
    package generics_practice_test;
    import java.util.Set;
    public class Main {
     
     
    	public static void main (String args[])
    	{
    		Set<String> a = new Set<String>();  //<- Error Given is: cannot initiate the Set<String> object
    	}
     
     
    }
    Last edited by arpansen; July 29th, 2014 at 06:06 AM.


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: problem in crearting a Set object(Set here refers to java.util.Set)

    The java.util.Set is an interface and NOT a class.
    Only classes can be initialized. You need to find a class which implements the interface, for example a HashSet but other Sets can be used as well.

  3. The Following 2 Users Say Thank You to Cornix For This Useful Post:

    arpansen (July 29th, 2014), GregBrannon (July 29th, 2014)

  4. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: problem in crearting a Set object(Set here refers to java.util.Set)

    Welcome to the Forum! Thanks for taking the time to learn to post code correctly, and if you haven't already, please read this topic to see other useful info for newcomers.

  5. The Following User Says Thank You to GregBrannon For This Useful Post:

    arpansen (July 29th, 2014)

Similar Threads

  1. SLF4J with java.util.logging - How to set log into files
    By amit1983 in forum Java Theory & Questions
    Replies: 2
    Last Post: December 7th, 2013, 03:17 PM
  2. how can i set an object in focus
    By ankushpruthi in forum What's Wrong With My Code?
    Replies: 10
    Last Post: October 1st, 2013, 07:01 AM
  3. Set and get method problem in java
    By Shania_01 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 10th, 2013, 10:16 AM
  4. Set headers for HttpServletRequest object?
    By FailMouse in forum Web Frameworks
    Replies: 3
    Last Post: December 1st, 2010, 03:00 PM
  5. How do you set an object in array to null value?
    By Arius in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 25th, 2010, 03:50 AM