newcoder1010 Posted October 12, 2020 Share Posted October 12, 2020 Hello, https://www.w3schools.com/java/showjava.asp?filename=demo_hashset_add package Hash; import java.util.HashSet; public class HashSet { public static void main(String[] args) { HashSet<String> cars = new HashSet<String>(); cars.add("Volvo"); cars.add("BMW"); cars.add("Ford"); cars.add("BMW"); cars.add("Mazda"); System.out.println(cars); } } Error: "The type HashSet is not generic; it cannot be parameterized with arguments <String>" Please advise! Link to comment Share on other sites More sharing options...
Funce Posted October 14, 2020 Share Posted October 14, 2020 This is because its being taken as your class "HashSet", You've overidden the class "HashSet" with your program called "HashSet", you may want to change it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now