类型Set不是通用的; 它不能使用参数进行参数化
我的Eclipse面临着这个奇怪的问题。 得到这个错误
The type Set is not generic; it cannot be parameterized with arguments
我再次清理并构建了我的项目。 检查我的配置构建路径并确保JRESystemLibrary在Order和Export中高于MavenDependencies 。
谷歌搜索,但我发现我的代码没有任何问题。 为什么错误弹出。
当您调用Set
它将被视为您的类 Set,而不是java.util.Set
。
将声明更改为java.util.Set
,它应该被解析。
你的主要方法认为Set是它所包含的类。
你想要java.util.Set
我的建议是重命名你的class级:p
我也经历了同样的错误,但只是通过改变项目的一些属性来解决它。
右键单击您的项目 – >属性 – >从右侧面板中选择“Java Build Path” – >选择“Order and Export”选项卡 – >单击您的JRE系统库或JDK库 – >单击“向上”按钮并将其移至第一个位置 – >单击“确定”并清理并构建项目。
如果有任何依赖,请对所有其他家属项目重复此操作。
它解决了我的问题,因为以前java文件正在挑选其他库和包不是来自jre包,因为它是按最后优先级设置的。
谢谢,Shwetank R.
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() Setids=driver.getWindowHandles(); Iterator 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()); } }
我面临同样的问题并遵循以下步骤
右键单击您的项目 – >属性 – >从右侧面板中选择“Java Build Path” – >选择“Order and Export”选项卡 – >并选中JRE系统库顶部或不存在ID是在TOP上选择此项并单击“应用”。 然后创建新类