R11G
R11G

Reputation: 1980

The type Set is not generic; it cannot be parameterized with arguments <Integer>

I am facing this weird problem with my Eclipse. Getting this error

The type Set is not generic; it cannot be parameterized with arguments <Integer>

I cleaned and build my project again. Checked my Configure Build path and ensured that JRESystemLibrary is above MavenDependencies in Order and Export.

Googled as well but I can't find any issue with my code. Why is the error popping up.

enter image description here

Upvotes: 4

Views: 17065

Answers (6)

Sibin Muhammed A R
Sibin Muhammed A R

Reputation: 1432

Rename your class to a different name.

or

Use the fully qualified name.

 java.util.Set<Integer> set = new HashSet<>();

or

You don't need to use the fully qualified name if you are using Java 11 or above.

You can use the var keyword, introduced in Java 10, to declare local variables without explicitly specifying the type.

var set = new HashSet<Integer>();

Upvotes: 0

kishore
kishore

Reputation: 29

I faced same issue and followed below steps

Right Click on your project --> Properties --> Select "Java Build Path" from Right hand side panel --> Select "Order and Export" tab --> and checked JRE system Library is present on top or not id it is present on TOP select this and click Apply. Then create new class

Upvotes: 2

Shwetank Rastogi
Shwetank Rastogi

Reputation: 111

I have also gone through the same error but it was resolved just by changing in some properties of project.

Right Click on your project --> Properties --> Select "Java Build Path" from Right hand side panel --> Select "Order and Export" tab --> Click on you JRE System Library or JDK Library --> Click on "Up" button and move it to first position --> Click Ok and clean & build your project.

Do repeat this for all other dependents project as well, if have any dependency.

It resolved my issue because previously the java files were picking other library and packages not from jre package as it was ordered set in last priority.

Thanks, Shwetank R.

Upvotes: 3

Shashi Singh
Shashi Singh

Reputation: 11

import java.util.Iterator;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import java.util.Set;

public class ChildWindow {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    WebDriver driver= new FirefoxDriver();
    driver.get("https://accounts.google.com/");
    driver.manage().window().maximize();
    System.out.println("Existing Url");
    System.out.println(driver.getTitle());
    System.out.println("Url-1");
    driver.findElement
    (By.xpath(".//*[@id='footer-list']/li[4] /a")).click();
    System.out.println(driver.getTitle());

    //get all windows ids -driver.getWindowHandles()
    Set<String>ids=driver.getWindowHandles();
     Iterator<String> it =ids.iterator();
     String Childid1=it.next();
     String Childid2=it.next();
     driver.switchTo().window(Childid2);
     System.out.println("2nd Url");
     System.out.println(driver.getTitle());


   }

  }

Upvotes: 1

sandymatt
sandymatt

Reputation: 5612

Your main method thinks Set is the class that it's contained in.

You want java.util.Set

My suggestion would be to rename your class :p

Upvotes: 7

Thihara
Thihara

Reputation: 6969

When you call Set it is being taken as your class Set, not java.util.Set.

Change the declaration to java.util.Set and it should be resolved.

Upvotes: 21

Related Questions