SlideShare a Scribd company logo
Core Java

Debasish Pratihari

Array :



In Java arrays are objects that represent a
group of contiguous memory locations of the
same type and referred to by the same name.



The element type for an array can be any
primitive data type or object.



All Java arrays are technically one-dimensional.
Two-dimensional arrays are arrays of arrays.



Declaring an array does not create an array
object or allocate space in memory; it creates a
variable with a reference to an array



Array variable declarations must indicate a
dimension by using []



All arrays are zero-based



Arrays must be indexed by int values or byte,
short or char values (as these can be promoted
to int)



Using a long index value to access an array
causes a compile error



Attempting to access an array with an index less
than 0 or greater than the length of the array
causes an ArrayIndexOutOfBoundsException
to be thrown at runtime



Since arrays are Objects they can be initialized
using the new operator



When created, arrays are automatically
initialized with the default value of their type



Array references declared as members are
initialized to null BUT array references declared
in methods are not initialized

Lecture/core/array/06

Page #1

feel the Technology…
Core Java

Debasish Pratihari

Examples of valid array declarations :



String[]s;



String s[];



String[][]s;



String s[][];



String[] s[];

Initializing Array :












String[ ] s = new String[100]; // default values: null
boolean[] b = new boolean[4]; // default values: false
int i[ ]= new int[5];
int[][] i = new int[10][10];
// default values: 0
String[] oneDimArray = { "abc","def","xyz" };
int[] array = null;
int[][] twoDimArray = { {1,2,3}, {4,5,6}, {7,8,9} };
int[] a = { 1, primes[2], c, (int)Math.pow(2,2) };
int[] arr = new int[] {1,2,3};
int[][] myArray = new int[5][];
int arrSize = 100;
String[] myArray = new String[arrSize];

Illegal Initialization of Array :






String[5] s;
int[] array = new int[];
int[][] myArray = new int[][5];
String[] s;
s = { "Lakshya", "debasish", "java"};

Lecture/core/array/06

Page #2

feel the Technology…
Core Java

Debasish Pratihari

Finding length of an Array :



Arrays have a length data field (read only),
specifying the number of elements in the array.



The length data field can be accessed through
the dot operator.



The bounds of an array are integers between 0
and length – 1



Example
for ( int k=0; k < a.length ; k++ )
System.out.println( a[ k ] );

Multidimensional Arrays:


Multidimensional arrays are implemented as
arrays of arrays. Multidimensional arrays are
declared by appending the appropriate number
of bracket pairs after the array name.



The number of elements in each direction need
not be specified in the declaration.



The number of elements in each direction need
not be equal.

Example of irregular Array :

int[][] irregular = { { 1 },
{ 2, 3 },
{ 4, 5, 6, 7 },
{0}
};

Lecture/core/array/06

Page #3

feel the Technology…
Core Java

Debasish Pratihari

An Example -Triangle Array :
Output

int[][] triangle = new int[10][];
for ( int j = 0; j<triangle.length ; j++ )
triangle[ j ] = new int[ j + 1 ];
for ( int i = 0 ; i < triangle.length ; i++ )
{
for ( int j = 0 ; j < triangle[i].length ; j++ )
System.out.print( triangle[i][j] + " " );
System.out.println();
}

0
00
000
0000
00000
000000
0000000
00000000
000000000
0000000000

Coping Array :
25% 



Arrays can be copied using the Java System
method arraycopy():
Signature:public static native void
arraycopy(Object src, int src_position, Object
dst, int dst_position, int length)
Parameters:
src - the source array.
src_position - start position (first cell to copy) in the
source array.
dst - the destination array.
dst_position - start position in the destination array.
length - the number of array elements to be copied.



By default, all Java arrays support the clone
method.

Things to Remember :


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.



Each item in an array is called an element



each element is accessed by its numerical
index.

Lecture/core/array/06

Page #4

feel the Technology…

More Related Content

What's hot

Lec 25 - arrays-strings
Lec 25 - arrays-stringsLec 25 - arrays-strings
Lec 25 - arrays-stringsPrincess Sam
 
array
array array
Array in C# 3.5
Array in C# 3.5Array in C# 3.5
Array in C# 3.5
Gopal Ji Singh
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
Tareq Hasan
 
C# Arrays
C# ArraysC# Arrays
C# Arrays
Hock Leng PUAH
 
Arrays in Java | Edureka
Arrays in Java | EdurekaArrays in Java | Edureka
Arrays in Java | Edureka
Edureka!
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
Martin Chapman
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
OXUS 20
 
Array&amp;string
Array&amp;stringArray&amp;string
Array&amp;string
chanchal ghosh
 
7array in c#
7array in c#7array in c#
7array in c#
Sireesh K
 
Two-dimensional array in java
Two-dimensional array in javaTwo-dimensional array in java
Two-dimensional array in java
Talha mahmood
 
Array and Collections in c#
Array and Collections in c#Array and Collections in c#
Array and Collections in c#
Umar Farooq
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
Janpreet Singh
 
Csharp4 arrays and_tuples
Csharp4 arrays and_tuplesCsharp4 arrays and_tuples
Csharp4 arrays and_tuplesAbed Bukhari
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
أحمد محمد
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
moazamali28
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
Shubham Sharma
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
Edureka!
 

What's hot (20)

Lec 25 - arrays-strings
Lec 25 - arrays-stringsLec 25 - arrays-strings
Lec 25 - arrays-strings
 
array
array array
array
 
Array in C# 3.5
Array in C# 3.5Array in C# 3.5
Array in C# 3.5
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
 
C# Arrays
C# ArraysC# Arrays
C# Arrays
 
Arrays in Java | Edureka
Arrays in Java | EdurekaArrays in Java | Edureka
Arrays in Java | Edureka
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 
Array&amp;string
Array&amp;stringArray&amp;string
Array&amp;string
 
7array in c#
7array in c#7array in c#
7array in c#
 
Two-dimensional array in java
Two-dimensional array in javaTwo-dimensional array in java
Two-dimensional array in java
 
Array and Collections in c#
Array and Collections in c#Array and Collections in c#
Array and Collections in c#
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
Csharp4 arrays and_tuples
Csharp4 arrays and_tuplesCsharp4 arrays and_tuples
Csharp4 arrays and_tuples
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
 

Viewers also liked

Carol Judge, Warwickshire County Council
Carol Judge, Warwickshire County CouncilCarol Judge, Warwickshire County Council
Carol Judge, Warwickshire County Council
Paul McElvaney
 
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Paul McElvaney
 
Reed business preso
Reed business presoReed business preso
Reed business preso
Sjef Kerkhofs
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
wejia
 
Reviewing Screen-Based Content
Reviewing Screen-Based ContentReviewing Screen-Based Content
Reviewing Screen-Based Content
Rhonda Bracey
 
Nilga Feb 2009
Nilga Feb 2009Nilga Feb 2009
Nilga Feb 2009
Paul McElvaney
 
Paragraphs and topic sentences
Paragraphs and topic sentencesParagraphs and topic sentences
Paragraphs and topic sentencesSussan Roo
 
عرض ملتقى النهائي جديد
عرض ملتقى النهائي جديدعرض ملتقى النهائي جديد
عرض ملتقى النهائي جديد
sabah alharby
 
Lezing abc
Lezing abcLezing abc
Lezing abc
Sjef Kerkhofs
 
クラウド
クラウドクラウド
クラウドyuu_2003
 
Systems engineering leidraad se gww door ms
Systems engineering leidraad se gww door msSystems engineering leidraad se gww door ms
Systems engineering leidraad se gww door ms
Marcel Seijner
 
Scotweb Presentation
Scotweb PresentationScotweb Presentation
Scotweb Presentation
Paul McElvaney
 
Learning Pool Social Care Webinar Presentation
Learning Pool Social Care Webinar PresentationLearning Pool Social Care Webinar Presentation
Learning Pool Social Care Webinar Presentation
Paul McElvaney
 
Worksheet
WorksheetWorksheet
Worksheet
Ng Lim
 
Learning pool community rewards
Learning pool community rewardsLearning pool community rewards
Learning pool community rewardsPaul McElvaney
 
Online Public Relations
Online Public RelationsOnline Public Relations
Online Public Relations
Sjef Kerkhofs
 
MISIÓN INTERCULTURALIDAD - 1E-A
MISIÓN INTERCULTURALIDAD - 1E-AMISIÓN INTERCULTURALIDAD - 1E-A
MISIÓN INTERCULTURALIDAD - 1E-A
Juan Serrano Pérez
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
Debasish Pratihari
 
Adding A Link To A Flick’R Photo
Adding A Link To A Flick’R PhotoAdding A Link To A Flick’R Photo
Adding A Link To A Flick’R Photo
Lutie
 

Viewers also liked (20)

Carol Judge, Warwickshire County Council
Carol Judge, Warwickshire County CouncilCarol Judge, Warwickshire County Council
Carol Judge, Warwickshire County Council
 
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
 
Reed business preso
Reed business presoReed business preso
Reed business preso
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
 
Reviewing Screen-Based Content
Reviewing Screen-Based ContentReviewing Screen-Based Content
Reviewing Screen-Based Content
 
Nilga Feb 2009
Nilga Feb 2009Nilga Feb 2009
Nilga Feb 2009
 
Paragraphs and topic sentences
Paragraphs and topic sentencesParagraphs and topic sentences
Paragraphs and topic sentences
 
عرض ملتقى النهائي جديد
عرض ملتقى النهائي جديدعرض ملتقى النهائي جديد
عرض ملتقى النهائي جديد
 
Lezing abc
Lezing abcLezing abc
Lezing abc
 
クラウド
クラウドクラウド
クラウド
 
Systems engineering leidraad se gww door ms
Systems engineering leidraad se gww door msSystems engineering leidraad se gww door ms
Systems engineering leidraad se gww door ms
 
Scotweb Presentation
Scotweb PresentationScotweb Presentation
Scotweb Presentation
 
Learning Pool Social Care Webinar Presentation
Learning Pool Social Care Webinar PresentationLearning Pool Social Care Webinar Presentation
Learning Pool Social Care Webinar Presentation
 
Worksheet
WorksheetWorksheet
Worksheet
 
Learning pool community rewards
Learning pool community rewardsLearning pool community rewards
Learning pool community rewards
 
Microcamp Milano
Microcamp MilanoMicrocamp Milano
Microcamp Milano
 
Online Public Relations
Online Public RelationsOnline Public Relations
Online Public Relations
 
MISIÓN INTERCULTURALIDAD - 1E-A
MISIÓN INTERCULTURALIDAD - 1E-AMISIÓN INTERCULTURALIDAD - 1E-A
MISIÓN INTERCULTURALIDAD - 1E-A
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Adding A Link To A Flick’R Photo
Adding A Link To A Flick’R PhotoAdding A Link To A Flick’R Photo
Adding A Link To A Flick’R Photo
 

Similar to Lecture 6

Class notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsClass notes(week 4) on arrays and strings
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
Class notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsClass notes(week 4) on arrays and strings
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
Unit-2.Arrays and Strings.pptx.................
Unit-2.Arrays and Strings.pptx.................Unit-2.Arrays and Strings.pptx.................
Unit-2.Arrays and Strings.pptx.................
suchitrapoojari984
 
arrays in c# including Classes handling arrays
arrays in c#  including Classes handling arraysarrays in c#  including Classes handling arrays
arrays in c# including Classes handling arrays
JayanthiM19
 
Lecture 7 arrays
Lecture   7 arraysLecture   7 arrays
Lecture 7 arrays
manish kumar
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
shafat6712
 
Arrays
ArraysArrays
CH1 ARRAY (1).pptx
CH1 ARRAY (1).pptxCH1 ARRAY (1).pptx
CH1 ARRAY (1).pptx
AnkitaVerma776806
 
ARRAYS.ppt
ARRAYS.pptARRAYS.ppt
ARRAYS.ppt
surajthakur474818
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
Intro C# Book
 
Module 7 : Arrays
Module 7 : ArraysModule 7 : Arrays
Module 7 : Arrays
Prem Kumar Badri
 
Arrays in java.pptx
Arrays in java.pptxArrays in java.pptx
Arrays in java.pptx
Nagaraju Pamarthi
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injavairdginfo
 
javaArrays.pptx
javaArrays.pptxjavaArrays.pptx
javaArrays.pptx
AshishNayyar11
 
Arrays are used to store multiple values in a single variable, instead of dec...
Arrays are used to store multiple values in a single variable, instead of dec...Arrays are used to store multiple values in a single variable, instead of dec...
Arrays are used to store multiple values in a single variable, instead of dec...
ssuser6478a8
 
ARRAYS.ppt
ARRAYS.pptARRAYS.ppt
ARRAYS.ppt
coding9
 
ARRAYS.ppt
ARRAYS.pptARRAYS.ppt
ARRAYS.ppt
ssuser99ca78
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
rohinitalekar1
 

Similar to Lecture 6 (20)

Class notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsClass notes(week 4) on arrays and strings
Class notes(week 4) on arrays and strings
 
Class notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsClass notes(week 4) on arrays and strings
Class notes(week 4) on arrays and strings
 
Unit-2.Arrays and Strings.pptx.................
Unit-2.Arrays and Strings.pptx.................Unit-2.Arrays and Strings.pptx.................
Unit-2.Arrays and Strings.pptx.................
 
arrays in c# including Classes handling arrays
arrays in c#  including Classes handling arraysarrays in c#  including Classes handling arrays
arrays in c# including Classes handling arrays
 
Lecture 7 arrays
Lecture   7 arraysLecture   7 arrays
Lecture 7 arrays
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
 
Arrays
ArraysArrays
Arrays
 
CH1 ARRAY (1).pptx
CH1 ARRAY (1).pptxCH1 ARRAY (1).pptx
CH1 ARRAY (1).pptx
 
ARRAYS.ppt
ARRAYS.pptARRAYS.ppt
ARRAYS.ppt
 
2 arrays
2   arrays2   arrays
2 arrays
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
 
Module 7 : Arrays
Module 7 : ArraysModule 7 : Arrays
Module 7 : Arrays
 
Arrays in java.pptx
Arrays in java.pptxArrays in java.pptx
Arrays in java.pptx
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
 
javaArrays.pptx
javaArrays.pptxjavaArrays.pptx
javaArrays.pptx
 
Arrays are used to store multiple values in a single variable, instead of dec...
Arrays are used to store multiple values in a single variable, instead of dec...Arrays are used to store multiple values in a single variable, instead of dec...
Arrays are used to store multiple values in a single variable, instead of dec...
 
ARRAYS.ppt
ARRAYS.pptARRAYS.ppt
ARRAYS.ppt
 
ARRAYS.ppt
ARRAYS.pptARRAYS.ppt
ARRAYS.ppt
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
 
Fp201 unit4
Fp201 unit4Fp201 unit4
Fp201 unit4
 

More from Debasish Pratihari

Lecture 24
Lecture 24Lecture 24
Lecture 24
Debasish Pratihari
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
Debasish Pratihari
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
Debasish Pratihari
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
Debasish Pratihari
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
Debasish Pratihari
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
Debasish Pratihari
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
Debasish Pratihari
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
Debasish Pratihari
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
Debasish Pratihari
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
Debasish Pratihari
 
Lecture 9
Lecture 9Lecture 9
Lecture 8
Lecture 8Lecture 8
Lecture 7
Lecture 7Lecture 7
Lecture 5
Lecture 5Lecture 5
Lecture 4
Lecture 4Lecture 4
Lecture 3
Lecture 3Lecture 3
Lecture 2
Lecture 2Lecture 2
Lecture 1
Lecture 1Lecture 1
Lecture25
Lecture25Lecture25

More from Debasish Pratihari (19)

Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture25
Lecture25Lecture25
Lecture25
 

Recently uploaded

Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 

Recently uploaded (20)

Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 

Lecture 6

  • 1. Core Java Debasish Pratihari Array :  In Java arrays are objects that represent a group of contiguous memory locations of the same type and referred to by the same name.  The element type for an array can be any primitive data type or object.  All Java arrays are technically one-dimensional. Two-dimensional arrays are arrays of arrays.  Declaring an array does not create an array object or allocate space in memory; it creates a variable with a reference to an array  Array variable declarations must indicate a dimension by using []  All arrays are zero-based  Arrays must be indexed by int values or byte, short or char values (as these can be promoted to int)  Using a long index value to access an array causes a compile error  Attempting to access an array with an index less than 0 or greater than the length of the array causes an ArrayIndexOutOfBoundsException to be thrown at runtime  Since arrays are Objects they can be initialized using the new operator  When created, arrays are automatically initialized with the default value of their type  Array references declared as members are initialized to null BUT array references declared in methods are not initialized Lecture/core/array/06 Page #1 feel the Technology…
  • 2. Core Java Debasish Pratihari Examples of valid array declarations :  String[]s;  String s[];  String[][]s;  String s[][];  String[] s[]; Initializing Array :            String[ ] s = new String[100]; // default values: null boolean[] b = new boolean[4]; // default values: false int i[ ]= new int[5]; int[][] i = new int[10][10]; // default values: 0 String[] oneDimArray = { "abc","def","xyz" }; int[] array = null; int[][] twoDimArray = { {1,2,3}, {4,5,6}, {7,8,9} }; int[] a = { 1, primes[2], c, (int)Math.pow(2,2) }; int[] arr = new int[] {1,2,3}; int[][] myArray = new int[5][]; int arrSize = 100; String[] myArray = new String[arrSize]; Illegal Initialization of Array :     String[5] s; int[] array = new int[]; int[][] myArray = new int[][5]; String[] s; s = { "Lakshya", "debasish", "java"}; Lecture/core/array/06 Page #2 feel the Technology…
  • 3. Core Java Debasish Pratihari Finding length of an Array :  Arrays have a length data field (read only), specifying the number of elements in the array.  The length data field can be accessed through the dot operator.  The bounds of an array are integers between 0 and length – 1  Example for ( int k=0; k < a.length ; k++ ) System.out.println( a[ k ] ); Multidimensional Arrays:  Multidimensional arrays are implemented as arrays of arrays. Multidimensional arrays are declared by appending the appropriate number of bracket pairs after the array name.  The number of elements in each direction need not be specified in the declaration.  The number of elements in each direction need not be equal. Example of irregular Array : int[][] irregular = { { 1 }, { 2, 3 }, { 4, 5, 6, 7 }, {0} }; Lecture/core/array/06 Page #3 feel the Technology…
  • 4. Core Java Debasish Pratihari An Example -Triangle Array : Output int[][] triangle = new int[10][]; for ( int j = 0; j<triangle.length ; j++ ) triangle[ j ] = new int[ j + 1 ]; for ( int i = 0 ; i < triangle.length ; i++ ) { for ( int j = 0 ; j < triangle[i].length ; j++ ) System.out.print( triangle[i][j] + " " ); System.out.println(); } 0 00 000 0000 00000 000000 0000000 00000000 000000000 0000000000 Coping Array : 25%    Arrays can be copied using the Java System method arraycopy(): Signature:public static native void arraycopy(Object src, int src_position, Object dst, int dst_position, int length) Parameters: src - the source array. src_position - start position (first cell to copy) in the source array. dst - the destination array. dst_position - start position in the destination array. length - the number of array elements to be copied.  By default, all Java arrays support the clone method. Things to Remember :  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.  Each item in an array is called an element  each element is accessed by its numerical index. Lecture/core/array/06 Page #4 feel the Technology…