英文:
error: incompatible types: CAP#1 cannot be converted to int[] (Java, Android Studio)
问题
我有
int [] nr_modes = characteristics.get(CameraCharacteristics.NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES);
我想将它更改为
for (CameraCharacteristics.Key<?> key : characteristics.getKeys()) {
check = key.getName();
check = check.toLowerCase();
if (check.contains("noise")){
int [] modes = characteristics.get(key)
}
这是用于调试,因为我有一些键无法通过characteristics.NAME_HERE访问,它们本身也是键。
错误是
error: 不兼容的类型:CAP#1无法转换为int[]
int [] modes = characteristics.get(key);
^
其中CAP#1是一个新的类型变量:
CAP#1扩展自capture of ?
英文:
I have
int [] nr_modes = characteristics.get(CameraCharacteristics.NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES);
And I want to change it to
for (CameraCharacteristics.Key <?> key : characteristics.getKeys()) {
check = key.getName();
check = check.toLowerCase();
if (check.contains("noise")){
int [] modes = characteristics.get(key)
}
This is for debugging as I have some keys I cannot access by characteristics.NAME_HERE, which they themselves are also keys.
The error is
error: incompatible types: CAP#1 cannot be converted to int[]
int [] modes = characteristics.get(key);
^
where CAP#1 is a fresh type-variable:
CAP#1 extends Object from capture of ?
答案1
得分: 1
如果有人在疑惑,我通过将其转换为整数来解决了这个问题:
从
int [] modes = characteristics.get(key);
到
int [] modes = (int[]) characteristics.get(key);
英文:
In case anyone was wondering, I fixed this problem by casting to an int
from
int [] modes = characteristics.get(key);
to
int [] modes = (int[]) characteristics.get(key);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论