Jump to content

The type HashSet is not generic; it cannot be parameterized with arguments <String>


newcoder1010
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...