Page 260 - computer science (868) class 11
P. 260
10
ARRAYS
Learning Objectives
10.1 Array 10.2 Need for an Array
10.3 Single-Dimensional Array 10.4 Different Operations on a Single-Dimensional Array
10.5 Insertion 10.6 Deletion
10.7 Merging 10.8 Double-Dimensional Array
10.9 Sorting Vs. Searching 10.10 Linear Search Vs. Binary Search
10.11 Bubble Sort Vs. Selection Sort 10.12 Single-Dimensional Array Vs. Double-Dimensional Array
You know that a variable can store one value at a time. Sometimes, the situation occurred that we need to store several
values of a similar type. In that case, we have to declare several variables. To avoid such situations, Java provides the
concept of an array. Java also provides strings to handle the textual information. In this chapter, we will learn about
arrays and strings.
10.1 ARRAY
An array is a collection of data of a similar type. In other words, an array is a group of variables accessed through a
common name. It can store a set of values of any primitive or non-primitive type. It is a composite data type. The
values stored in an array are known as array elements. In an array, the values are stored one after another and each
value has an index starting from 0 which means that the first value is stored at the 0th index, the second value is stored
at the 1st index, and so on. For example,
Array Values/Elements 5 10 8 7 1 6 4 3 11
Index 0 1 2 3 4 5 6 7 8
th
st
In the above example, you can see that value 5 is stored at 0 index, value 10 is stored at the 1 index, and the last
th
value 11 is stored at the 8 index. The number of elements specifies the length of the array. In the above example,
there are nine elements in the array, so the length of the array is 9.
Definition
Arrays can be defined as a set of variables which contains values of same data types having same variable name but
different subscripts required to separate the values. Thus, we can say that an array is a composite data type.
258258 Touchpad Computer Science-XI

