不兼容的类型:推理变量E有不兼容的界限:未能初始化ChoiceBox

问题描述:

我不明白为什么这不起作用,当我尝试初始化ChoiceBoxes。不兼容的类型:推理变量E有不兼容的界限:未能初始化ChoiceBox

@FXML 
private ChoiceBox<?> humanChoiceB; 

String[] numbers = new String[]{"0", "1", "2", "3", "4", "5", "6", "7"}; 

humanChoiceB.setItems(FXCollections.observableArrayList(numbers)); 

当我编译时,指出错误显示出来:

incompatible types: inference variable E has incompatible bounds 
equality constraints: capture#1 of ? 
lower bounds: java.lang.String 

奇怪的是,同一段代码工作对我的NetBeans的一个本地项目,但不能在我目前的Maven项目(也在NetBeans IDE上,或者说NetBeans Maven)。

紧时间表。非常感谢您的帮助。

你的宣言

@FXML 
private ChoiceBox<?> humanChoiceB; 

应该

@FXML 
private ChoiceBox<String> humanChoiceB; 
+0

一个愚蠢丢失了怎么办!多谢,伙计。我可能需要休息一下。 –