- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is an array in Java?
An array is a data structure/container/object that stores a fixed-size sequential collection of elements of the same type. The size/length of the array is determined at the time of creation.
The position of the elements in the array is called as index or subscript. The first element of the array is stored at the index 0 and, the second element is at the index 1 and so on.
Each element in an array is accessed using an expression which contains the name of the array followed by the index of the required element in square brackets.
For example, if an array of five elements is created with name myArray, you can access the element of the array at index 3 as:
myArray[3]

Example
public class ArrayExample { public static void main(String args[]){ //Declaring an array int[] myArray = {233, 783, 453}; //Printing the array for(int i=0; i<myArray.length; i++){ System.out.println(myArray[i]); } } }
Output
233 783 453
- Related Articles
- What is an array data structure in Java?
- What is an anonymous array and explain with an example in Java?
- Determining If an Object Is an Array in Java
- What is an array in C#?
- What is a Multidimensional array in Java?
- Is an array a primitive type or an object in Java?
- Returning an array in Java
- What is an array class in C#?
- What is an abstraction in Java?
- what is an iterator in Java?
- What are the different ways of copying an array into another array in Java?
- Loop through an array in Java
- Check if a value is present in an Array in Java
- Convert an ArrayList to an Array with zero length Array in Java
- How to convert an object array to an integer array in Java?

Advertisements