SlideShare a Scribd company logo
Array
BY ASHAH HOUSE OF SOFTWARE
ASHAH HOUSE OF SOFTWARE
Outline
What is Array ?
Array Declaration
Array Allocation
Array Initialization
Two dimensional Array
Array Types( Symmetrical & Asymmetrical)
For each loop
ASHAH HOUSE OF SOFTWARE
What is Array?
•An array is a container object . That holds a fixed number of values of a single type.
•Array is complex type of variable
•Array is also object.
•It is data structure.
•Contain a fixed number of values of same type .
•Each item in an array is called an element
•Element can be accessed through index number
ASHAH HOUSE OF SOFTWARE
Array Declaration
•an array declaration has two components:
• Array type
• Array name
•Array can be declared as:
• int arr[];
• int []arr;
• int[] arr; //preferred way
• int is a data type of array “arr” is the name of Array “[]” is for index.
•Brackets [] are special symbols indicating that this variable holds an array.
ASHAH HOUSE OF SOFTWARE
Array Allocation
•Array Allocation means size of array.
•Array can be allocated as:
• arr[]=new int[10];
•Array is fixed can not be resize after allocation.
•New allocate memory for Array.
•Length Property:
• it gives the length/size of the array.
• Syntax:
• arrayName.length
ASHAH HOUSE OF SOFTWARE
Array Initialization
•Array can be initialized by individual index
• arr[0]=1;
• arr[1]=2;
•Array can be declare , allocate and initialize in single statement as
• int arr[]=new int[]{1,2,3,4,5,6,7,8,9,10};
• Int arr[]={1,2,3,4,5,6,7,9,10};
ASHAH HOUSE OF SOFTWARE
Two Dimensional Array
•Array can be more than one dimension
• Two dimensional array or we can say Array into Array or Nested Array
•Two Dimensional Array can be Declare as:
• int arr[][];
• int[][] arr;
• int [][]arr;
•Allocate as:
• int arr[][]=new arr[2][3];
• Int arr[][]=new arr[2][];
•Initialized as:
• arr[0][0]=1;
• arr[0][1]=2;
• arr[1][0]=3;
• arr[1][1]=4;
ASHAH HOUSE OF SOFTWARE
Two Dimensional Array Cont…
•Two Dimensional Array can be declare, allocate and initialized in one statement.
• int arr[][]=new int[][]{ {1,2} , {3,4} };
• int arr[][]={ {1,2} , {3,4} };
ASHAH HOUSE OF SOFTWARE
Array Types( Symmetrical & Asymmetrical)
•Array can be Symmetrical or Asymmetrical.
•Symmetrical Array:
• All nested array have same size
• As : int arr[][]=new int[2][3];
•Asymmetrical Array:
• Nested array can be vary in size
• As: int arr[][]=new int[2][];
• Not need to give size to nested array.
ASHAH HOUSE OF SOFTWARE
For Each loop
•Also known as enhanced for loop.
•Foreach is also loop specially used for array.
•Enables to traverse the complete array sequentially without using an index variable.
•Syntax:
Int arr[]={1,,2,3,4,5};
For(int v : arr ){
System.out.println(v);
}
ASHAH HOUSE OF SOFTWARE
Copy Array
•The System class have “arraycopy” method.
•Syntax:
• Public static void arraycopy(object srcArr, int startingSrc,object destArr, int startingDest, int length)
•Calling:
• System.arraycopy(srcArr,5,destArr,0,5);
•For copy an array first you have to declare and allocate array.
ASHAH HOUSE OF SOFTWARE
Array Class
•The java.util.Arrays class contains various static methods.
•Sorting:
• public static void sort(Object[] a)
• Sort into ascending
•Searching:
• public static int binarySearch(Object[] a, Object key)
• Return: index
•Comparing:
• public static boolean equals(long[] a, long[] a2)
• Return : true
•Filling:
• public static void fill(int[] a, int val)
• Assign value to specified.
•Note: These methods are overloaded for all primitive types.
ASHAH HOUSE OF SOFTWARE

More Related Content

What's hot (20)

PPTX
Java arrays
BHUVIJAYAVELU
 
PPTX
Array in c#
Prem Kumar Badri
 
PPTX
Arrays in Java
Abhilash Nair
 
PPT
Java Arrays
Jussi Pohjolainen
 
ODP
C++ arrays part1
Subhasis Nayak
 
PPTX
Array
Anil Neupane
 
PPT
Array
PRN USM
 
PPT
Array in Java
Shehrevar Davierwala
 
PPTX
Array lecture
Joan Saño
 
PDF
intorduction to Arrays in java
Muthukumaran Subramanian
 
PPTX
Two-dimensional array in java
Talha mahmood
 
PPTX
Arrays in C++
Kashif Nawab
 
PPTX
ARRAY
ayush raj
 
PPTX
Arrays in java language
Hareem Naz
 
PDF
Week06
hccit
 
PPT
C++ Arrays
أحمد محمد
 
PPT
Mesics lecture 8 arrays in 'c'
eShikshak
 
PPT
Lecture 2a arrays
Victor Palmar
 
PPT
Arrays Class presentation
Neveen Reda
 
Java arrays
BHUVIJAYAVELU
 
Array in c#
Prem Kumar Badri
 
Arrays in Java
Abhilash Nair
 
Java Arrays
Jussi Pohjolainen
 
C++ arrays part1
Subhasis Nayak
 
Array
PRN USM
 
Array in Java
Shehrevar Davierwala
 
Array lecture
Joan Saño
 
intorduction to Arrays in java
Muthukumaran Subramanian
 
Two-dimensional array in java
Talha mahmood
 
Arrays in C++
Kashif Nawab
 
ARRAY
ayush raj
 
Arrays in java language
Hareem Naz
 
Week06
hccit
 
C++ Arrays
أحمد محمد
 
Mesics lecture 8 arrays in 'c'
eShikshak
 
Lecture 2a arrays
Victor Palmar
 
Arrays Class presentation
Neveen Reda
 

Viewers also liked (15)

PPT
Java lezione 2
Sergio Ronchi
 
PPT
Basic Elements of Java
Prof. Erwin Globio
 
PPTX
basic core java up to operator
kamal kotecha
 
PPT
Core java Basics
RAMU KOLLI
 
PPT
Java Basics
sunilsahu07
 
PPTX
Introduction to Array ppt
sandhya yadav
 
PPTX
2- Dimensional Arrays
Education Front
 
PPTX
C++ lecture 04
HNDE Labuduwa Galle
 
PDF
Array en java operaciones
Emerson Garay
 
PPTX
C++ programming (Array)
طارق بالحارث
 
PPTX
Array in c++
Mahesha Mano
 
PDF
C++ ARRAY WITH EXAMPLES
Farhan Ab Rahman
 
PPTX
Introduction to Java Strings, By Kavita Ganesan
Kavita Ganesan
 
PPT
Core java concepts
Ram132
 
PPT
02 c++ Array Pointer
Tareq Hasan
 
Java lezione 2
Sergio Ronchi
 
Basic Elements of Java
Prof. Erwin Globio
 
basic core java up to operator
kamal kotecha
 
Core java Basics
RAMU KOLLI
 
Java Basics
sunilsahu07
 
Introduction to Array ppt
sandhya yadav
 
2- Dimensional Arrays
Education Front
 
C++ lecture 04
HNDE Labuduwa Galle
 
Array en java operaciones
Emerson Garay
 
C++ programming (Array)
طارق بالحارث
 
Array in c++
Mahesha Mano
 
C++ ARRAY WITH EXAMPLES
Farhan Ab Rahman
 
Introduction to Java Strings, By Kavita Ganesan
Kavita Ganesan
 
Core java concepts
Ram132
 
02 c++ Array Pointer
Tareq Hasan
 
Ad

Similar to Array in Java (20)

PPT
Core java day2
Soham Sengupta
 
DOCX
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
PPTX
Arrays in Data Structure and Algorithm
KristinaBorooah
 
DOCX
Java R20 - UNIT-3.docx
Pamarthi Kumar
 
PPT
Comp102 lec 8
Fraz Bakhsh
 
PPTX
ARRAYS.pptx
akila m
 
PDF
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
PPTX
Chapter6 (4) (1).pptx plog fix down more
mohammadalali41
 
PDF
Arrays a detailed explanation and presentation
riazahamed37
 
PPTX
6_Array.pptx
shafat6712
 
PPTX
javaArrays.pptx
AshishNayyar11
 
PPTX
Arrays in programming
TaseerRao
 
PPT
Eo gaddis java_chapter_07_5e
Gina Bullock
 
PDF
Java arrays
Kuppusamy P
 
PPT
17-Arrays en java presentación documento
DiegoGamboaSafla
 
PPT
ch06.ppt
AqeelAbbas94
 
PPT
ch06.ppt
ansariparveen06
 
PPT
array Details
shivas379526
 
PPT
ch06.ppt
chandrasekar529044
 
PPTX
Arrays introduction- JAVA
Hamna_sheikh
 
Core java day2
Soham Sengupta
 
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
Arrays in Data Structure and Algorithm
KristinaBorooah
 
Java R20 - UNIT-3.docx
Pamarthi Kumar
 
Comp102 lec 8
Fraz Bakhsh
 
ARRAYS.pptx
akila m
 
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
Chapter6 (4) (1).pptx plog fix down more
mohammadalali41
 
Arrays a detailed explanation and presentation
riazahamed37
 
6_Array.pptx
shafat6712
 
javaArrays.pptx
AshishNayyar11
 
Arrays in programming
TaseerRao
 
Eo gaddis java_chapter_07_5e
Gina Bullock
 
Java arrays
Kuppusamy P
 
17-Arrays en java presentación documento
DiegoGamboaSafla
 
ch06.ppt
AqeelAbbas94
 
ch06.ppt
ansariparveen06
 
array Details
shivas379526
 
Arrays introduction- JAVA
Hamna_sheikh
 
Ad

Recently uploaded (20)

PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 

Array in Java

  • 1. Array BY ASHAH HOUSE OF SOFTWARE ASHAH HOUSE OF SOFTWARE
  • 2. Outline What is Array ? Array Declaration Array Allocation Array Initialization Two dimensional Array Array Types( Symmetrical & Asymmetrical) For each loop ASHAH HOUSE OF SOFTWARE
  • 3. What is Array? •An array is a container object . That holds a fixed number of values of a single type. •Array is complex type of variable •Array is also object. •It is data structure. •Contain a fixed number of values of same type . •Each item in an array is called an element •Element can be accessed through index number ASHAH HOUSE OF SOFTWARE
  • 4. Array Declaration •an array declaration has two components: • Array type • Array name •Array can be declared as: • int arr[]; • int []arr; • int[] arr; //preferred way • int is a data type of array “arr” is the name of Array “[]” is for index. •Brackets [] are special symbols indicating that this variable holds an array. ASHAH HOUSE OF SOFTWARE
  • 5. Array Allocation •Array Allocation means size of array. •Array can be allocated as: • arr[]=new int[10]; •Array is fixed can not be resize after allocation. •New allocate memory for Array. •Length Property: • it gives the length/size of the array. • Syntax: • arrayName.length ASHAH HOUSE OF SOFTWARE
  • 6. Array Initialization •Array can be initialized by individual index • arr[0]=1; • arr[1]=2; •Array can be declare , allocate and initialize in single statement as • int arr[]=new int[]{1,2,3,4,5,6,7,8,9,10}; • Int arr[]={1,2,3,4,5,6,7,9,10}; ASHAH HOUSE OF SOFTWARE
  • 7. Two Dimensional Array •Array can be more than one dimension • Two dimensional array or we can say Array into Array or Nested Array •Two Dimensional Array can be Declare as: • int arr[][]; • int[][] arr; • int [][]arr; •Allocate as: • int arr[][]=new arr[2][3]; • Int arr[][]=new arr[2][]; •Initialized as: • arr[0][0]=1; • arr[0][1]=2; • arr[1][0]=3; • arr[1][1]=4; ASHAH HOUSE OF SOFTWARE
  • 8. Two Dimensional Array Cont… •Two Dimensional Array can be declare, allocate and initialized in one statement. • int arr[][]=new int[][]{ {1,2} , {3,4} }; • int arr[][]={ {1,2} , {3,4} }; ASHAH HOUSE OF SOFTWARE
  • 9. Array Types( Symmetrical & Asymmetrical) •Array can be Symmetrical or Asymmetrical. •Symmetrical Array: • All nested array have same size • As : int arr[][]=new int[2][3]; •Asymmetrical Array: • Nested array can be vary in size • As: int arr[][]=new int[2][]; • Not need to give size to nested array. ASHAH HOUSE OF SOFTWARE
  • 10. For Each loop •Also known as enhanced for loop. •Foreach is also loop specially used for array. •Enables to traverse the complete array sequentially without using an index variable. •Syntax: Int arr[]={1,,2,3,4,5}; For(int v : arr ){ System.out.println(v); } ASHAH HOUSE OF SOFTWARE
  • 11. Copy Array •The System class have “arraycopy” method. •Syntax: • Public static void arraycopy(object srcArr, int startingSrc,object destArr, int startingDest, int length) •Calling: • System.arraycopy(srcArr,5,destArr,0,5); •For copy an array first you have to declare and allocate array. ASHAH HOUSE OF SOFTWARE
  • 12. Array Class •The java.util.Arrays class contains various static methods. •Sorting: • public static void sort(Object[] a) • Sort into ascending •Searching: • public static int binarySearch(Object[] a, Object key) • Return: index •Comparing: • public static boolean equals(long[] a, long[] a2) • Return : true •Filling: • public static void fill(int[] a, int val) • Assign value to specified. •Note: These methods are overloaded for all primitive types. ASHAH HOUSE OF SOFTWARE