SlideShare a Scribd company logo
1 of 14
Prepared by-
Shaishav shah(170120116094)
Guided by – Prof. Nisha Patel
Gandhinagar Institute of Technology
SUBJECT - OOPJ (2150704)
Arrays in Java
WHATISARRAY?
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
• DECLARA
TION
• CONSTRUCTION
• INITIALIZATION
• TWODIMENSIONALARRA
Y
• MULTIDIMENSIONALARRA
Y
WHYARRAY?
Problem?
•Implement an application that will calculate 100
students exam average.
•Variables needed?
int studentA; int studentB; int studentC; int studentD;
...
SEVERALVARIABLESATONCE?
Arraycomesto the rescue!
• Justalist of variables
• Declarethe array
int [] array;
• Initialize the array and set it'ssize
array =new array[3];
• Storevaluesinto 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
worksbut not preferredway
preferredway
DECLARATIONCOUNT…
• Array declaration in C++
int hardy[10];
• Array declaration in Java
int [] hardy;
hardy=new int[10];
DECLARATIONCOUNT…
• 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];
Hardyarray
INITIALIZATION
• Initialization isloading the array withthe valies.
Int[] hardy=newint[5]
hardy[0]=32
;
hardy[1]=12
;
hardy[2]=66
;
32 12 66 54 43
0 1 2 3 4
index
TWODIMENSIONALARRAY
• 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=newint[2];
• Mark[0]=newint[3];
• Mark[1]=newint[4];
0 1
0 1 2 0 1 2 3
MULTIDIMENSIONALARRAY
• Int[][][] hardy=newint[2][3][2];
0 1
0 1 2 0 1 2
0 1 0 1 0 1 0 1 0 1 0 1
Arrays in java oopj

More Related Content

Similar to Arrays in java oopj

Java Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptxJava Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptxrangariprajwal4554
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptxquipoin04
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...MaruMengesha
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structuresagorolabs
 
Keywords and classes
Keywords and classesKeywords and classes
Keywords and classesRavi_Kant_Sahu
 
1. Overview of Java
1. Overview of Java1. Overview of Java
1. Overview of JavaNilesh Dalvi
 
4. Classes and Methods
4. Classes and Methods4. Classes and Methods
4. Classes and MethodsNilesh Dalvi
 
Pi j3.4 data-structures
Pi j3.4 data-structuresPi j3.4 data-structures
Pi j3.4 data-structuresmcollison
 
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Sagar Verma
 
Cancer genomics big_datascience_meetup_july_14_2014
Cancer genomics big_datascience_meetup_july_14_2014Cancer genomics big_datascience_meetup_july_14_2014
Cancer genomics big_datascience_meetup_july_14_2014Shyam Sarkar
 
Core java concepts
Core    java  conceptsCore    java  concepts
Core java conceptsChikugehlot
 

Similar to Arrays in java oopj (19)

OOPs with java
OOPs with javaOOPs with java
OOPs with java
 
Java Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptxJava Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptx
 
Arrays in java.pptx
Arrays in java.pptxArrays in java.pptx
Arrays in java.pptx
 
Java for newcomers
Java for newcomersJava for newcomers
Java for newcomers
 
JavaYDL6
JavaYDL6JavaYDL6
JavaYDL6
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
 
Java keywords
Java keywordsJava keywords
Java keywords
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
 
Keywords and classes
Keywords and classesKeywords and classes
Keywords and classes
 
1. Overview of Java
1. Overview of Java1. Overview of Java
1. Overview of Java
 
4. Classes and Methods
4. Classes and Methods4. Classes and Methods
4. Classes and Methods
 
Ppt chapter09
Ppt chapter09Ppt chapter09
Ppt chapter09
 
Pi j3.4 data-structures
Pi j3.4 data-structuresPi j3.4 data-structures
Pi j3.4 data-structures
 
Java 103
Java 103Java 103
Java 103
 
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
 
Cancer genomics big_datascience_meetup_july_14_2014
Cancer genomics big_datascience_meetup_july_14_2014Cancer genomics big_datascience_meetup_july_14_2014
Cancer genomics big_datascience_meetup_july_14_2014
 
Core java concepts
Core    java  conceptsCore    java  concepts
Core java concepts
 

More from ShaishavShah8

Diffie hellman key algorithm
Diffie hellman key algorithmDiffie hellman key algorithm
Diffie hellman key algorithmShaishavShah8
 
Constructor oopj
Constructor oopjConstructor oopj
Constructor oopjShaishavShah8
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphicsShaishavShah8
 
Classification of debuggers sp
Classification of debuggers spClassification of debuggers sp
Classification of debuggers spShaishavShah8
 
Parallel and perspective projection in 3 d cg
Parallel and perspective projection in 3 d cgParallel and perspective projection in 3 d cg
Parallel and perspective projection in 3 d cgShaishavShah8
 
Asymptotic notations ada
Asymptotic notations adaAsymptotic notations ada
Asymptotic notations adaShaishavShah8
 
Classical cyphers python programming
Classical cyphers python programmingClassical cyphers python programming
Classical cyphers python programmingShaishavShah8
 
Logics for non monotonic reasoning-ai
Logics for non monotonic reasoning-aiLogics for non monotonic reasoning-ai
Logics for non monotonic reasoning-aiShaishavShah8
 
Rdd transformations bda
Rdd transformations bdaRdd transformations bda
Rdd transformations bdaShaishavShah8
 
Introduction to data warehouse dmbi
Introduction to data warehouse dmbiIntroduction to data warehouse dmbi
Introduction to data warehouse dmbiShaishavShah8
 
Lan, wan, man mcwc
Lan, wan, man mcwcLan, wan, man mcwc
Lan, wan, man mcwcShaishavShah8
 
Introduction to xml, uses of xml wt
Introduction to xml, uses of xml wtIntroduction to xml, uses of xml wt
Introduction to xml, uses of xml wtShaishavShah8
 
Agile process se
Agile process seAgile process se
Agile process seShaishavShah8
 
Applications of huffman coding dcdr
Applications of huffman coding dcdrApplications of huffman coding dcdr
Applications of huffman coding dcdrShaishavShah8
 
Cookie management using jsp a java
Cookie management using jsp  a javaCookie management using jsp  a java
Cookie management using jsp a javaShaishavShah8
 
Login control .net
Login control .netLogin control .net
Login control .netShaishavShah8
 
Rdd transformations
Rdd transformationsRdd transformations
Rdd transformationsShaishavShah8
 
Introduction to data warehouse
Introduction to data warehouseIntroduction to data warehouse
Introduction to data warehouseShaishavShah8
 

More from ShaishavShah8 (19)

Diffie hellman key algorithm
Diffie hellman key algorithmDiffie hellman key algorithm
Diffie hellman key algorithm
 
Constructor oopj
Constructor oopjConstructor oopj
Constructor oopj
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Classification of debuggers sp
Classification of debuggers spClassification of debuggers sp
Classification of debuggers sp
 
Parallel and perspective projection in 3 d cg
Parallel and perspective projection in 3 d cgParallel and perspective projection in 3 d cg
Parallel and perspective projection in 3 d cg
 
Asymptotic notations ada
Asymptotic notations adaAsymptotic notations ada
Asymptotic notations ada
 
Classical cyphers python programming
Classical cyphers python programmingClassical cyphers python programming
Classical cyphers python programming
 
Logics for non monotonic reasoning-ai
Logics for non monotonic reasoning-aiLogics for non monotonic reasoning-ai
Logics for non monotonic reasoning-ai
 
Rdd transformations bda
Rdd transformations bdaRdd transformations bda
Rdd transformations bda
 
Introduction to data warehouse dmbi
Introduction to data warehouse dmbiIntroduction to data warehouse dmbi
Introduction to data warehouse dmbi
 
Lan, wan, man mcwc
Lan, wan, man mcwcLan, wan, man mcwc
Lan, wan, man mcwc
 
Introduction to xml, uses of xml wt
Introduction to xml, uses of xml wtIntroduction to xml, uses of xml wt
Introduction to xml, uses of xml wt
 
Agile process se
Agile process seAgile process se
Agile process se
 
Applications of huffman coding dcdr
Applications of huffman coding dcdrApplications of huffman coding dcdr
Applications of huffman coding dcdr
 
Cookie management using jsp a java
Cookie management using jsp  a javaCookie management using jsp  a java
Cookie management using jsp a java
 
Login control .net
Login control .netLogin control .net
Login control .net
 
Rdd transformations
Rdd transformationsRdd transformations
Rdd transformations
 
LAN, WAN, MAN
LAN, WAN, MANLAN, WAN, MAN
LAN, WAN, MAN
 
Introduction to data warehouse
Introduction to data warehouseIntroduction to data warehouse
Introduction to data warehouse
 

Recently uploaded

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Recently uploaded (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Arrays in java oopj