
Array Concepts using JAVA
Presentation
•
Science, Computers
•
University
•
Hard
Suganthi Duraiswamy
Used 10+ times
FREE Resource
10 Slides • 0 Questions
1
by Dr. D. Suganthi, AP/MCA
SRM University, Ramapuram
2
An array is a container object that holds a fixed number of values of a single type.
The length of an array is established when the array is created. After creation, its length is fixed.
Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.
To declare an array, define the variable type with square brackets []
3
The variables in the array are ordered and each have an index beginning from 0.
Java array can be also be used as a static field, a local variable or a method parameter.
The size of an array must be specified by an int or short value and not long.
The direct superclass of an array type is Object.
Every array type implements the interfaces Cloneable and java.io.Serializable.
4
The array can contain primitives (int, char, etc.) as well as object (or non-primitive) references of a class depending on the definition of the array.
In case of primitive data types, the actual values are stored in contiguous memory locations.
5
6
Creating, Initializing, and Accessing an Array:
One-Dimensional Arrays : The general form of a one-dimensional array declaration is
int intArray[]; //declaring array
intArray = new int[20]; // allocating memory to array (or)
int[] intArray = new int[20]; // combining both statements in one
7
where the size of the array and variables of array are already known, array literals can be used.
int[] intArray = new int[]{ 1,2,3,4,5,6,7,8,9,10 }; // Declaring array literal
8
Each element in the array is accessed via its index. The index begins with 0 and ends at (total array size)-1. All the elements of array can be accessed using Java for Loop.
// accessing the elements of the specified array
for (int i = 0; i < arr.length; i++)
System.out.println("Element at index " + i + " : "+ arr[i]);
9
class GFG {
public static void main (String[] args) {
// declares an Array of integers.
int[] arr;
// allocating memory for 5 integers.
arr = new int[5];
// initialize the first elements of the array
arr[0] = 10;
// initialize the second elements of the array
arr[1] = 20; //so on... arr[2] = 30; arr[3] = 40; arr[4] = 50;
10
// accessing the elements of the specified array for (int i = 0; i < arr.length; i++) System.out.println("Element at index " + i + " : "+ arr[i]); } } |
Output:
Element at index 0 : 10
Element at index 1 : 20
Element at index 2 : 30
Element at index 3 : 40
Element at index 4 : 50
by Dr. D. Suganthi, AP/MCA
SRM University, Ramapuram
Show answer
Auto Play
Slide 1 / 10
SLIDE
Similar Resources on Wayground
6 questions
Week 3 CAD 154
Presentation
•
University
6 questions
WJM quiz
Presentation
•
University
6 questions
Cognitive behavioural therapy
Presentation
•
University
6 questions
Web Technologies
Presentation
•
University
6 questions
宇宙と季節
Presentation
•
KG
7 questions
PCIT21 WEEK 2
Presentation
•
University
7 questions
Python
Presentation
•
University
8 questions
multimedia1
Presentation
•
KG
Popular Resources on Wayground
10 questions
Safety Day 2026 – Student Review
Quiz
•
9th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
15 questions
Rounding Decimals
Quiz
•
5th Grade
Discover more resources for Science
20 questions
Disney Trivia
Quiz
•
University
10 questions
Spanish Greetings and Goodbyes!
Presentation
•
6th Grade - University
20 questions
Physical or Chemical Change/Phases
Quiz
•
8th Grade - University
39 questions
Unit 7 Key Terms
Quiz
•
11th Grade - University
25 questions
SER and Subject Pronouns
Quiz
•
8th Grade - University
38 questions
Unit 6 Key Terms
Quiz
•
11th Grade - University
19 questions
Key Concepts in Buddhism
Quiz
•
University
0 questions
Cell Domain Basic Review (Biology)
Quiz
•
University