O'Reilly logo

Java Programming by Hari Mohan Pandey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5 Working with Array in Java

5.1 INTRODUCTION

An array is a data structure which can store multiple elements of same type under one name. In other words, an array is a collection of variables of the same type, all of which are referred by a common name. The specific element of an array is accessed by an index. One single variable can store only one value at a time. In order to work with multiple data items at the same time, all of which have some common features, e.g., age of all students, salary of all employees, etc. then instead of creating separate variable for each data item an array can be used.

The declaration of an array is done in the following way:

int arr [];

By the above statement an array is named as arr . While declaring an array, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required