4

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

R11G
  • 1,941
  • 8
  • 26
  • 37

5 Answers5

21

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.

Thihara
  • 7,031
  • 2
  • 29
  • 56
7

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

yamafontes
  • 5,552
  • 1
  • 18
  • 18
3

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.

2

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

kishore
  • 29
  • 1
1
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());


   }

  }