Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Arrays

Rating
-
Sold
-
Pages
9
Uploaded on
20-09-2025
Written in
2025/2026

It have all the basic concepts of array. Which would help you to understand it well.

Institution
Course

Content preview

Chapter 15
Arrays
Definition:
1. Array is defined as collection of similar type of data values.
2. An array is container object that contains/stores a fixed number of values of
similar type.
3. An array is a memory structure created that contains a number of values with
same variable name but different subscript (index) in order to deal with a number of
data values

Need of array
When a variable is declared, user is allowed to just assign a single value to a
variable. As soon as the user assigns a new value to a variable the previous value is
automatically replaced by the new value. This shows that a variable is capable of
storing a single value at once. If we want to store multiple values in a variable at
once, we use a logical structure known as an array.

Advantages of array
1. Allows storing multiple elements (values) of same type using a single name
(variable).
2. Easier access to any element using the index.
3. Easy to manipulate and store large data.

Disadvantages of array
1. Fixed size. Cannot be increased or decreased once declared.
2. Can store a single type of values only.

Single Dimensional Array
Characteristics
1. Fixed Length
2. Can store both primitive and non primitive values
3. Array variable is itself an object or reference variable
4. Array’s index starts with 0 and ends with N-1. Here, N stands for the number
of elements.
5. Elements are entered and accessed using same function.
function – arrayname[index].
6. Length of an array can be returned using the length (a final variable that stores
the number of element that can be entered in the array).
int var = arrayname.length;

Creating and initializing the single dimensional array
1. Using new keyword (dynamic)
Syntax –
<datatype> <array name []> = <new> <datatype[size]>;
for(int i=0;i< arrayname.length; i++)

, {
arrayname[i] = reading (inputting) methods ;
}

Example –
int a[] = new int[10];
for(int i=0;i< a.length; i++)
{
a [i] = Scanner object.nextInt() ; //or
Integer.parseInt(BufferedReaderobject.readLine());
}

2. Direct creation (static)
Syntax –
<datatype> <array name []> = {element1, element2, ..... element };

Example –
int a[] = {10, 20, 30, 40, 50};

Operations performed in array:-
1. Searching
2. Sorting
3. Mapping
4. Deletion
5. Insertion
6. Merging

Searching
Searching is the operation or process performed in an array to search for an element
whether it is available or not. Searching is done by two methods. –
1. Linear Search
2. Binary Search
1. Linear Search – Linear Search uses the method of traversing (traversal is a
method in which all the elements of the array are accessed). In this the
element is compared and searched from the first index number (i.e with the
first element) to the last index (till the last element). The process of
comparison and searching is continued till the element is searched (if present).

import java.util.*;
class Linear_Search
{
public static void main()
{
Scanner ob = new Scanner(System.in);

Connected book

Written for

Institution
Secondary school
Course
School year
1

Document information

Uploaded on
September 20, 2025
Number of pages
9
Written in
2025/2026
Type
Class notes
Professor(s)
Nitish
Contains
10

Subjects

$6.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
rawatsh65

Get to know the seller

Seller avatar
rawatsh65
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
7 months
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions