类型不匹配:无法从int转换为Integer

时间:2020-09-09 17:47:34

标签: java arrays string

我正在尝试制作二维数组。

这是代码: 公共类TwoDimensionalArray {

public static void main(String[] args) {
    
    Integer str[][]=new Integer[3][3];

    
    str [0][0]=10; the error is here 'cannot convert from int to integer'
    

1 个答案:

答案 0 :(得分:0)

Integer和int是不同的数据类型。如果未指定,则该语言会将其假定为int。我将解决如下问题:

public static void main(String[] args) {

    Integer str[][]=new Integer[3][3];
    Integer myInt = 10;
    str [0][0]=myInt;
}
相关问题