Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

What is an Array Data Structure in Java



Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. Following are the important terms to understand the concept of Array.

  • Element − Each item stored in an array is called an element.

  • Index − Each location of an element in an array has a numerical index, which is used to identify the element.

Example

Live Demo

public class ArrayExample {
   public static void main(String args[]){
      int myArray[] = {44, 69, 89, 635};
      
      for (int i = 0; i<myArray.length; i++){
         System.out.println(myArray[i]);
      }
   }
}

Output

44
69
89
635
Updated on: 2019-07-30T22:30:20+05:30

224 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements