

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- What is an array data structure in Java?
- What is an anonymous array and explain with an example in Java?
- What is an array in C#?
- Determining If an Object Is an Array in Java
- What is an array class in C#?
- What is an abstraction in Java?
- what is an iterator in Java?
- What is an array and what is it used for?
- What is a Multidimensional array in Java?
- What is an Ant build in Java?
- What is an Inner class in Java?
- Is an array a primitive type or an object in Java?
- What is an array of structures in C language?
- What is an array and how is it used for?
- What is an I/O filter in Java?
Advertisements