为什么int [] []无法转换为int?

时间:2019-09-21 16:52:23

标签: java arrays

这个二维数组怎么办? :\

final private int jawel[] = {1, 2, 3, 4, 5,};
final private int jawel_lvlenchdata[][] = {{0,  0}, ..., {1673543,  3546345},};

int lvl = 2;

for(int i = 0; i<=jawel.length-1; i++)
{
    int jawel = jawel[i];

    if(jawel==1)
    {
      int ench = jawel_lvlenchdata[lvl][0];
    }
}

当尝试转换时:int ench = jawel_lvlenchdata[lvl][0]; 总是获得lvl插入的数组值:'|

1 个答案:

答案 0 :(得分:-1)

只需修改您的代码及其工作即可。

    public class Lvl {
    public static void main(String[] args)
    {
    final int jawel[] = {1, 2, 3, 4, 5,};
    final  int jawel_lvlenchdata[][] = {{0,  0},{1,2}, {1673543,  3546345}};
    int ench=0;

    int lvl = 2;

    for(int i = 0; i<=jawel.length-1; i++)
    {
        int jawel1 = jawel[i];

        if(jawel1==1)
        {
            ench = jawel_lvlenchdata[lvl][0];
        }
    }
    System.out.println(ench);
}

}