SlideShare a Scribd company logo
PROGRAMMING IN JAVA
Arzath Areeff
WHAT IS ARRAY?
Java provides a data structure, the array, which
stores a fixed-size sequential collection of
elements of the same type. An array is used to
store a collection of data, but it is often more
useful to think of an array as a collection of
variables of the same type.
ARRAYS
• DECLARATION
• CONSTRUCTION
• INITIALIZATION
• TWO DIMENSIONAL ARRAY
• MULTI DIMENSIONAL ARRAY
WHY ARRAY?
Problem?
• Implement an application that will calculate 100
students exam average.
• Variables needed?
int studentA;
int studentB;
int studentC;
int studentD;
...
SEVERAL VARIABLES AT ONCE?
Array comes to the rescue!
• Just a list of variables
• Declare the array
int [] array;
• Initialize the array and set it's size
array = new array[3];
• Store values into array
array[0] = 2;
array[1] = 3;
array[2] = 7;
DECLARATION
• Declaring Arrays:
Int[] mark;
Byte[] age;
Double[] height;
Int mark[];
Byte age[];
Double height[];
Data type
Array Name
works but not preferred way
preferred way
DECLARATION COUNT…
• Array declaration in C++
int hardy[10];
• Array declaration in Java
int [] hardy;
hardy =new int[10];
DECLARATION COUNT…
• Storage for the array itself is not allocated
until you use “new”.
• For initializing method the “new” command is
not needed.
int [] hardy={5,3,7,89,2};
CONSTRUCTION
Int [] hardy;
hardy=new int[5];
In single line
Int[] hardy=new int[5];
Hardy array
INITIALIZATION
• Initialization is loading the array with the valies.
Int[] hardy=new int[5]
hardy[0]=32;
hardy[1]=12;
hardy[2]=66;
hardy[3]=54;
hardy[4]=43;
32 12 66 54 43
0 1 2 3 4
index
TWO DIMENSIONAL ARRAY
• Int[][] hardy=new int[2][3];
hardy[0][0]=32;
hardy[0][1]=12;
hardy[0][2]=66;
hardy[1][0]=54;
hardy[1][1]=43;
hardy[1][2]=36;
32 12 66 54 43 36
0 1
0 1 2 0 1 2
TWO DIMENSIONAL ARRAY - NON
UNIFORM
• Int[][] hardy=new int[2];
• Mark[0]=new int[3];
• Mark[1]=new int[4];
0 1
0 1 2 0 1 2 3
MULTI DIMENSIONAL ARRAY
• Int[][][] hardy=new int[2][3][2];
0 1
0 1 2 0 1 2
0 1 0 1 0 1 0 1 0 1 0 1
Peace & Love

More Related Content

What's hot

Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
Ravi Kant Sahu
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
Nahian Ahmed
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
PhD Research Scholar
 
Java IO
Java IOJava IO
Java IO
UTSAB NEUPANE
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
Shraddha
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
Spotle.ai
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
harsh kothari
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Pavith Gunasekara
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
Hitesh Kumar
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
Vinod Kumar
 
Array in Java
Array in JavaArray in Java
Array in Java
Shehrevar Davierwala
 
Java Tokens
Java  TokensJava  Tokens
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
CPD INDIA
 
Files in java
Files in javaFiles in java
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 

What's hot (20)

Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Interface in java
Interface in javaInterface in java
Interface in java
 
OOP java
OOP javaOOP java
OOP java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
Java IO
Java IOJava IO
Java IO
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
Java arrays
Java arraysJava arrays
Java arrays
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
 
Array in Java
Array in JavaArray in Java
Array in Java
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
 
Files in java
Files in javaFiles in java
Files in java
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 

Similar to Arrays in java

Arrays in java oopj
Arrays in java oopjArrays in java oopj
Arrays in java oopj
ShaishavShah8
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
ssuser8698eb
 
Javascript Arrays related PowerPoint slide set
Javascript Arrays related PowerPoint slide setJavascript Arrays related PowerPoint slide set
Javascript Arrays related PowerPoint slide set
ChobodiDamsaraniPadm
 
OOPs with java
OOPs with javaOOPs with java
OOPs with java
AAKANKSHA JAIN
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
Surbhi Yadav
 
Basics of array.pptx
Basics of array.pptxBasics of array.pptx
Basics of array.pptx
PRASENJITMORE2
 
Cso gaddis java_chapter8
Cso gaddis java_chapter8Cso gaddis java_chapter8
Cso gaddis java_chapter8mlrbrown
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
rishi ram khanal
 
Lec 1.5 Object Oriented Programming
Lec 1.5 Object Oriented ProgrammingLec 1.5 Object Oriented Programming
Lec 1.5 Object Oriented Programming
Badar Waseer
 
2 Arrays & Strings.pptx
2 Arrays & Strings.pptx2 Arrays & Strings.pptx
2 Arrays & Strings.pptx
aarockiaabinsAPIICSE
 
Arrays in java.pptx
Arrays in java.pptxArrays in java.pptx
Arrays in java.pptx
Nagaraju Pamarthi
 
PHP array 1
PHP array 1PHP array 1
PHP array 1
Mudasir Syed
 
Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)
Talha mahmood
 
Mod 12
Mod 12Mod 12
Mod 12
obrienduke
 
C
CC
CPP05 - Arrays
CPP05 - ArraysCPP05 - Arrays
CPP05 - Arrays
Michael Heron
 
Array
ArrayArray
Array
PRN USM
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & Arrays
Eng Teong Cheah
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
heena94
 
Arrays
ArraysArrays
Arrays
swathi reddy
 

Similar to Arrays in java (20)

Arrays in java oopj
Arrays in java oopjArrays in java oopj
Arrays in java oopj
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
 
Javascript Arrays related PowerPoint slide set
Javascript Arrays related PowerPoint slide setJavascript Arrays related PowerPoint slide set
Javascript Arrays related PowerPoint slide set
 
OOPs with java
OOPs with javaOOPs with java
OOPs with java
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Basics of array.pptx
Basics of array.pptxBasics of array.pptx
Basics of array.pptx
 
Cso gaddis java_chapter8
Cso gaddis java_chapter8Cso gaddis java_chapter8
Cso gaddis java_chapter8
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Lec 1.5 Object Oriented Programming
Lec 1.5 Object Oriented ProgrammingLec 1.5 Object Oriented Programming
Lec 1.5 Object Oriented Programming
 
2 Arrays & Strings.pptx
2 Arrays & Strings.pptx2 Arrays & Strings.pptx
2 Arrays & Strings.pptx
 
Arrays in java.pptx
Arrays in java.pptxArrays in java.pptx
Arrays in java.pptx
 
PHP array 1
PHP array 1PHP array 1
PHP array 1
 
Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)
 
Mod 12
Mod 12Mod 12
Mod 12
 
C
CC
C
 
CPP05 - Arrays
CPP05 - ArraysCPP05 - Arrays
CPP05 - Arrays
 
Array
ArrayArray
Array
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & Arrays
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
 
Arrays
ArraysArrays
Arrays
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
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
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
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
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
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: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.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
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
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
 
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
 
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
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
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
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
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: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.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...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
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
 
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
 
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...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Arrays in java

  • 2. WHAT IS ARRAY? Java provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
  • 3. ARRAYS • DECLARATION • CONSTRUCTION • INITIALIZATION • TWO DIMENSIONAL ARRAY • MULTI DIMENSIONAL ARRAY
  • 4. WHY ARRAY? Problem? • Implement an application that will calculate 100 students exam average. • Variables needed? int studentA; int studentB; int studentC; int studentD; ...
  • 5. SEVERAL VARIABLES AT ONCE? Array comes to the rescue! • Just a list of variables • Declare the array int [] array; • Initialize the array and set it's size array = new array[3]; • Store values into array array[0] = 2; array[1] = 3; array[2] = 7;
  • 6. DECLARATION • Declaring Arrays: Int[] mark; Byte[] age; Double[] height; Int mark[]; Byte age[]; Double height[]; Data type Array Name works but not preferred way preferred way
  • 7. DECLARATION COUNT… • Array declaration in C++ int hardy[10]; • Array declaration in Java int [] hardy; hardy =new int[10];
  • 8. DECLARATION COUNT… • Storage for the array itself is not allocated until you use “new”. • For initializing method the “new” command is not needed. int [] hardy={5,3,7,89,2};
  • 9. CONSTRUCTION Int [] hardy; hardy=new int[5]; In single line Int[] hardy=new int[5]; Hardy array
  • 10. INITIALIZATION • Initialization is loading the array with the valies. Int[] hardy=new int[5] hardy[0]=32; hardy[1]=12; hardy[2]=66; hardy[3]=54; hardy[4]=43; 32 12 66 54 43 0 1 2 3 4 index
  • 11. TWO DIMENSIONAL ARRAY • Int[][] hardy=new int[2][3]; hardy[0][0]=32; hardy[0][1]=12; hardy[0][2]=66; hardy[1][0]=54; hardy[1][1]=43; hardy[1][2]=36; 32 12 66 54 43 36 0 1 0 1 2 0 1 2
  • 12. TWO DIMENSIONAL ARRAY - NON UNIFORM • Int[][] hardy=new int[2]; • Mark[0]=new int[3]; • Mark[1]=new int[4]; 0 1 0 1 2 0 1 2 3
  • 13. MULTI DIMENSIONAL ARRAY • Int[][][] hardy=new int[2][3][2]; 0 1 0 1 2 0 1 2 0 1 0 1 0 1 0 1 0 1 0 1