Monday, 6 January 2020

Anonymous arrays example in java

import java.util.Scanner;


public class MyClass {
    public static void display(int a[])
    {
        for(int ele:a)
            System.out.println(ele);
    }
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("enter 3 numbers");
        display(new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt()});
    }
}

No comments:

Post a Comment