Horje
input array through scanner in java Code Example
how to get an array as input in java
    public class TakingInput {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        System.out.println("enter number of elements");

        int n=s.nextInt();

        int arr[]=new int[n];

        System.out.println("enter elements");

        for(int i=0;i<n;i++){//for reading array
            arr[i]=s.nextInt();

        }

        for(int i: arr){ //for printing array

            System.out.println(i);

        }


    }

}
input array through scanner in java
public static void main (String[] args)
{
    Scanner input = new Scanner(System.in);
    double[] numbers = new double[5];

    for (int i = 0; i < numbers.length; i++)
    {
        System.out.println("Please enter number");
        numbers[i] = input.nextDouble();
    }
}




Java

Related
LocalDateTime to XMLGregorianCalendar Code Example LocalDateTime to XMLGregorianCalendar Code Example
bungeecord plugin add configs Code Example bungeecord plugin add configs Code Example
Unable to find bundled Java version. Code Example Unable to find bundled Java version. Code Example
java stop program Code Example java stop program Code Example
ocha in japanese Code Example ocha in japanese Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9