Create Array Length & Element on Run Time
public class Array
{
public static void main (String[] args)
{
System.out.println("Enter the Array size -: ");
int limit = Integer.parseInt(System.console().readLine());
int [] a = new int [limit];
for(int i=0;i<=a.length-1;i++)
a[i] = Integer.parseInt(System.console().readLine());
for(int i=0;i<=a.length-1;i++)
System.out.printf(" %d ,",a[i]);
System.out.println();
}
}
No comments:
Post a Comment
Thank You !