Fully automatic array

Fully automatic array:

Now In this Blog we are learning how to create a fully automatic array. The size of the array will be given by the user and ofcourse The value inside the array will also be taken form the user..

package com.ritesh;

import java.sql.SQLOutput;
import java.util.Scanner;

public class auto_array {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter the size of the array");
byte n1= sc.nextByte();
int arr[]=new int[n1];
System.out.println("Enter "+n1+" number of element on the array");
for(int i=0;i<n1;i++){
arr[i]=sc.nextInt();
}
sc.close();
for(int i=0;i<arr.length;i++){
System.out.println("Element on array index is "+arr[i]);
}

}
}






















Comments