简体   繁体   中英

input cannot be resolved : Using Scanner class and Array

import java.util.Scanner; class Arrayy {

public static void main(String a[])
{
    Scanner sc = new Scanner (System.in);
    double arr[] = new double[5];
    for (int i = 1 ; i<arr.length; i++)
    {
        System.out.println("Enter The Stuff: ");     
        arr[i] = **input**.nextInt();

    }
}
}

The place where i have marked bold shows an exception that "input cannot be resolved"

can someone please help, although its very basic.

Your Scanner variable is called sc , not input .

public static void main(String a[])
{
    Scanner sc = new Scanner (System.in);
    double arr[] = new double[5];
    for (int i = 1 ; i<arr.length; i++)
    {
        System.out.println("Enter The Stuff: ");     
        arr[i] = sc.nextInt();

    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM