java - Type Set does not take parameters -


package set;  import java.util.*;  public class set  {    public static void main(string[] args)   {     string [] things = {"appple", "bob", "ham", "bob", "bacon"};     list<string> list = arrays.aslist(things);      system.out.printf("%s ", list);     system.out.println();      set<string> set = new hashset<string>(list);     system.out.printf("%s ", set);    }  }  

when try run program keep getting error set declaration. doing wrong?

rename public class set class name doesn't hide java.util.set.

your custom set class doesn't take type parameters. that's why set<string> doesn't pass compilation.

for example:

package set;  import java.util.*;  public class settest  {     public static void main(string[] args)     {         string [] things = {"appple", "bob", "ham", "bob", "bacon"};         list<string> list = arrays.aslist(things);          system.out.printf("%s ", list);         system.out.println();          set<string> set = new hashset<string>(list);         system.out.printf("%s ", set);       }  } 

Comments

Popular posts from this blog

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -