Input and output in array in java language.

 import java.util.*;

public class array {

    public static void main(String[] args) {

        int size;

        Scanner sc=new Scanner(System.in);

        System.out.println("enter the size of array=");

         size =sc.nextInt();

        int number[]=new int[size];

        System.out.println("enter the numbers=");

        for(int i=0; i<size; i++){

            number[i]=sc.nextInt();

        }

        System.out.println(" numbers are=");

        for(int i=0; i<size; i++ ){

            System.out.println(number[i]);

        }

    }

}

■》 Output->

Enter the size of array= 4

enter the numbers=

1

23

45

3

numbers are=>

1

23

45

3

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.