【问题标题】:Using genio with array将 genio 与数组一起使用
【发布时间】:2017-03-19 08:55:22
【问题描述】:

您好,我正在尝试让一个程序运行,该程序将要求用户使用 bluej 输入数组,为此我计划使用 Genio,但是当我在下面键入代码时,我收到以下消息:

不兼容的类型:int 无法转换为 int[]

public class Arrays
{
    public int[] numbers;

    public void testIntegerArray()
    {
        numbers = new int[4];

        for (int i = 0; i < numbers.length; i++) {
            numbers = Genio.getInteger();
            System.out.println(numbers[i]);
        }
    }
}

【问题讨论】:

    标签: java arrays bluej


    【解决方案1】:

    Genio.getInteger(); // 返回一个整数

    您正在将一个整数分配给您不能的数组。
    要将整数添加到您需要的数组中:

    numbers[i] = Genio.getInteger(); //your forgot the [i]
    

    【讨论】:

      猜你喜欢
      • 2018-08-17
      • 2015-10-05
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多