Java 类型 Set 不是通用的;它不能用参数 <Integer> 参数化

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19374315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 16:33:19  来源:igfitidea点击:

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

javaeclipse

提问by R11G

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

我的 Eclipse 面临这个奇怪的问题。收到此错误

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

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 JRESystemLibraryis above MavenDependenciesin Order and Export.

我再次清理并构建了我的项目。经过我的配置构建路径,并确保JRESystemLibrary高于MavenDependencies订单和出口。

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

也用谷歌搜索,但我找不到我的代码有任何问题。为什么会弹出错误。

enter image description here

在此处输入图片说明

采纳答案by Thihara

When you call Setit is being taken as your classSet, not java.util.Set.

当您调用Set它时,它被视为您的类Set,而不是java.util.Set.

Change the declaration to java.util.Setand it should be resolved.

将声明更改为java.util.Set,应该可以解决。

回答by yamafontes

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

您的主要方法认为 Set 是它所包含的类。

You want java.util.Set

你想要 java.util.Set

My suggestion would be to rename your class :p

我的建议是重命名你的班级:p

回答by Shashi Singh

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());


   }

  }

回答by Shwetank Rastogi

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.

右键单击您的项目--> 属性--> 从右侧面板中选择“Java 构建路径”--> 选择“订购和导出”选项卡--> 单击您的 JRE 系统库或 JDK 库--> 单击“向上”按钮并将其移动到第一个位置 --> 单击“确定”并清理并构建您的项目。

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.

它解决了我的问题,因为以前 java 文件选择了其他库和包,而不是从 jre 包中选择的,因为它是在最后一个优先级中设置的。

Thanks, Shwetank R.

谢谢,Shwetank R。

回答by kishore

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

右键单击您的项目--> 属性--> 从右侧面板中选择“Java 构建路径”--> 选择“订购和导出”选项卡--> 并检查 JRE 系统库是否位于顶部出现在 TOP 选择此项并单击应用。然后创建新类