
What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop?

Hi Friend,
Try the following code:
import java.util.*;
class ArrayExample2
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int array[]=new int[5];
System.out.println("Enter Array Elements: ");
for(int i=0;i<array.length;i++){
array[i]=input.nextInt();
}
System.out.println("Your Array Elements are: ");
for(int i=0;i<array.length;i++){
System.out.println(array[i]);
}
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.