java program for creating an array and displaying its elements

import java.io.*;
import java.util.Scanner;

/**
 *
 * @author mithi
 */
public class Arrayelement {

 
    public static void main(String[] args) {
        int num,i;
    System.out.println("Enter the limit of array");
    Scanner sc=new Scanner(System.in);
    num=sc.nextInt();
    int array_name[]=new int [100];
    System.out.println("Enter the element in the array one by one");
    for(i=0;i<num;i++)
    {
        array_name[i]=sc.nextInt();
    }
   
    System.out.println("Entered array is ");
    for(i=0;i<num;i++)
        System.out.println(array_name[i]);
    }

 
   
}
out-
Enter the limit of array
5
Enter the element in the array one by one
45
12
89
32
78
Entered array is 
45
12
89
32
78
BUILD SUCCESSFUL (total time: 12 seconds)

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation