错误:不兼容的类型:CAP#1 无法转换为int[](Java,Android Studio)

huangapple go评论124阅读模式
英文:

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 &lt;?&gt; key : characteristics.getKeys()) {
	check = key.getName();
    check = check.toLowerCase();
    if (check.contains(&quot;noise&quot;)){
       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);

huangapple
  • 本文由 发表于 2020年9月9日 07:19:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/63802761.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定