// Java program to illustrate creating an array
// of integers, puts some values in the array,
// and prints each value to standard output.
class ArraySample { public static void main(String[] args) { // declares an Array of integers. int[] arr; // allocating memory for 5 integers. arr = new int[5]; // initialize the first elements of the array arr[0] = 10; // initialize the second elements of the array arr[1] = 20; //so on... arr[2] = 30; arr[3] = 40; arr[4] = 50; // accessing the elements of the specified array for (int i = 0; i < arr.length; i++) System.out.println("Element at index " + i + " : " + arr[i]); } }
Output
Element at index 0 : 10
Element at index 1 : 20
Element at index 2 : 30
Element at index 3 : 40
Element at index 4 : 50
Limitations:
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc