SlideShare a Scribd company logo
1 of 24
Arrays
Introduction
● Arrays are dynamically created objects
● Components - These variables are called the components. All are in same
type
● An array object contains a number of variables.(empty - Array has no
elements/components)
● index (location of the component)
● length of the array
Example 1
public class Arrayxsample {
public static void main(String[] args) {
int a[] = {1};
System.out.println(a[0]);
}
}
Example 2
public class Arrayxsample {
public static void main(String[] args) {
int a[] = {1,2,3,4,5};
System.out.println(a[3]);
}
}
Example 3
public class Arrayxsample {
public static void main(String[] args) {
int [] a = {4,3};
System.out.println(a[1]);
}
}
Example 4
public class Arrayxsample {
public static void main(String[] args) {
int [] a = {"4","3"};
System.out.println(a[1]);
}
}
Example 5
public class Arrayxsample {
public static void main(String[] args) {
int [] a = {1,2};
System.out.println(a[5]);
}
}
Declaring and allocation
int intArray[]; //declaring array
intArray = new int[20]; // allocating memory to array
Example 6
public class Arrayxsample {
public static void main(String[] args) {
int a[] = new int[5];
System.out.println(a[3]);
}
}
Example 7
public class Arrayxsample {
public static void main(String[] args) {
int [] a = new int [5];
a[0]=5;
a [4]=1;
System.out.println(a[4]);
}
}
Example 8
public class Arrayxsample {
public static void main(String[] args) {
int [2] a = new int [];
System.out.println(a[1]);
}
}
Example 9
public class Arrayxsample {
public static void main(String[] args) {
int [2] a = int a [];
System.out.println(a[1]);
}
}
Example 10
public class Arrayxsample {
public static void main(String[] args) {
int [] a = new int [4];
System.out.println(a[5]);
}
}
Example 11
public class Arrayxsample {
public static void main(String[] args) {
int [] a = new int [20];
for(int i =0;i<20;i++) {
a[i]=i;
}
System.out.println(a[15]);
}
}
Example 12
public class Arrayxsample {
public static void main(String[] args) {
int[] intArray = new int[]{ 1,2,3,4,5,6,7,8,9,10 };
System.out.println(intArray[5]);
}
}
expand this
public class Arrayxsample {
public static void main(String[] args) {
byte[] apple, orange, cake[];
int x,y[],z[];
}
}
Example 13
public class Arrayxsample {
public static void main(String[] args) {
int[] intArray = new int[]{ 1,2,3,4,5,6,7,8,9,10 };
System.out.println(intArray.length);
}
}
Example 14
public class Arrayxsample {
public static void main(String[] args) {
int[][] intArray = {{1,2},{3,4,5}};
System.out.println(intArray[0][1]);
System.out.println(intArray[1][0]);
System.out.println(intArray[1][2]);
}
}
Example 15
public class Arrayxsample {
public static void main(String[] args) {
int[][][] intArray = {{{1,2},{3,4}},{{5},{6,7,8}},{{9},{10,11,12}}};
System.out.println(intArray[0][1][0]);
System.out.println(intArray[1][0][0]);
System.out.println(intArray[2][1][2]);
}
}
Example 16
public class Arrayxsample {
public static void main(String[] args) {
int i,j,k;
int[][][] intArray = new int[100][100][100] ;
for(i=0,j=0,k=0;(i>10 || j> 0 && k>0);i++,j=j+2,k++) {
intArray[i][j][k]= (i+j)*k;
}
System.out.println(intArray[0][0][0]);
}
}
References
• https://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html
• https://docs.oracle.com/javase/10/docs/api/java/util/Arrays.html
futuretekez@gmail.com
Keep In Touch
+94765632363
@FutureteKez
@10Giants

More Related Content

What's hot

What's hot (20)

Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheet
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
 
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
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
C arrays
C arraysC arrays
C arrays
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
 
array
array array
array
 
C# Arrays
C# ArraysC# Arrays
C# Arrays
 
Multi dimensional array
Multi dimensional arrayMulti dimensional array
Multi dimensional array
 
Java Foundations: Lists, ArrayList<T>
Java Foundations: Lists, ArrayList<T>Java Foundations: Lists, ArrayList<T>
Java Foundations: Lists, ArrayList<T>
 
18. Java associative arrays
18. Java associative arrays18. Java associative arrays
18. Java associative arrays
 
Array lecture
Array lectureArray lecture
Array lecture
 
Array
ArrayArray
Array
 
Arrays in C
Arrays in CArrays in C
Arrays in C
 
Array in Java
Array in JavaArray in Java
Array in Java
 
Chapter 6 arrays part-1
Chapter 6   arrays part-1Chapter 6   arrays part-1
Chapter 6 arrays part-1
 
1 D Arrays in C++
1 D Arrays in C++1 D Arrays in C++
1 D Arrays in C++
 
intorduction to Arrays in java
intorduction to Arrays in javaintorduction to Arrays in java
intorduction to Arrays in java
 
Oop lecture7
Oop lecture7Oop lecture7
Oop lecture7
 

Similar to Java arrays

Given Starter Fileimport java.util.Arrays; Encapsulates.pdf
Given Starter Fileimport java.util.Arrays;   Encapsulates.pdfGiven Starter Fileimport java.util.Arrays;   Encapsulates.pdf
Given Starter Fileimport java.util.Arrays; Encapsulates.pdfarchanaemporium
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginnersishan0019
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdfakkhan101
 
Operators
OperatorsOperators
Operatorsvvpadhu
 
Java Programming- 1) Write a recursive method that finds and returns t.docx
Java Programming- 1) Write a recursive method that finds and returns t.docxJava Programming- 1) Write a recursive method that finds and returns t.docx
Java Programming- 1) Write a recursive method that finds and returns t.docxmichael1810
 
Java Generics
Java GenericsJava Generics
Java Genericsjeslie
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdffreddysarabia1
 

Similar to Java arrays (20)

Java generics
Java genericsJava generics
Java generics
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
 
final year project center in Coimbatore
final year project center in Coimbatorefinal year project center in Coimbatore
final year project center in Coimbatore
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 
Generics
GenericsGenerics
Generics
 
Chap1 array
Chap1 arrayChap1 array
Chap1 array
 
Arrays
ArraysArrays
Arrays
 
Given Starter Fileimport java.util.Arrays; Encapsulates.pdf
Given Starter Fileimport java.util.Arrays;   Encapsulates.pdfGiven Starter Fileimport java.util.Arrays;   Encapsulates.pdf
Given Starter Fileimport java.util.Arrays; Encapsulates.pdf
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginners
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
07+08slide.pptx
07+08slide.pptx07+08slide.pptx
07+08slide.pptx
 
Operators
OperatorsOperators
Operators
 
Array list
Array listArray list
Array list
 
Java ppt
Java pptJava ppt
Java ppt
 
Java Programming- 1) Write a recursive method that finds and returns t.docx
Java Programming- 1) Write a recursive method that finds and returns t.docxJava Programming- 1) Write a recursive method that finds and returns t.docx
Java Programming- 1) Write a recursive method that finds and returns t.docx
 
STS4022 Exceptional_Handling
STS4022  Exceptional_HandlingSTS4022  Exceptional_Handling
STS4022 Exceptional_Handling
 
JDK 8
JDK 8JDK 8
JDK 8
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 

More from Maneesha Caldera

More from Maneesha Caldera (20)

An Overview of Social media analatics
An Overview of Social media analaticsAn Overview of Social media analatics
An Overview of Social media analatics
 
What is the programming language you need to learn
What is the programming language you need to learnWhat is the programming language you need to learn
What is the programming language you need to learn
 
Presentation
PresentationPresentation
Presentation
 
Java if else condition - powerpoint persentation
Java if else condition - powerpoint persentationJava if else condition - powerpoint persentation
Java if else condition - powerpoint persentation
 
Mobile cloud computing - Introduction
Mobile cloud computing - IntroductionMobile cloud computing - Introduction
Mobile cloud computing - Introduction
 
Android - Listview with source code
Android - Listview with source codeAndroid - Listview with source code
Android - Listview with source code
 
React js Introduction
React js IntroductionReact js Introduction
React js Introduction
 
Android - Values folder
Android - Values folderAndroid - Values folder
Android - Values folder
 
Machine Learning - Supervised learning
Machine Learning - Supervised learningMachine Learning - Supervised learning
Machine Learning - Supervised learning
 
C# - Windows Forms - Creating exe file
C# - Windows Forms - Creating exe fileC# - Windows Forms - Creating exe file
C# - Windows Forms - Creating exe file
 
C# Memory management
C# Memory managementC# Memory management
C# Memory management
 
C# Strings
C# StringsC# Strings
C# Strings
 
C# - Windows forms - lesson 2
C# - Windows forms -  lesson 2C# - Windows forms -  lesson 2
C# - Windows forms - lesson 2
 
C# session 01
C# session 01C# session 01
C# session 01
 
Node
NodeNode
Node
 
Lesson 2
Lesson 2Lesson 2
Lesson 2
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
Html 2
Html 2Html 2
Html 2
 
Html 1
Html 1Html 1
Html 1
 
Java arrays
Java arraysJava arrays
Java arrays
 

Recently uploaded

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 

Recently uploaded (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 

Java arrays

  • 2. Introduction ● Arrays are dynamically created objects ● Components - These variables are called the components. All are in same type ● An array object contains a number of variables.(empty - Array has no elements/components) ● index (location of the component) ● length of the array
  • 3. Example 1 public class Arrayxsample { public static void main(String[] args) { int a[] = {1}; System.out.println(a[0]); } }
  • 4. Example 2 public class Arrayxsample { public static void main(String[] args) { int a[] = {1,2,3,4,5}; System.out.println(a[3]); } }
  • 5. Example 3 public class Arrayxsample { public static void main(String[] args) { int [] a = {4,3}; System.out.println(a[1]); } }
  • 6. Example 4 public class Arrayxsample { public static void main(String[] args) { int [] a = {"4","3"}; System.out.println(a[1]); } }
  • 7. Example 5 public class Arrayxsample { public static void main(String[] args) { int [] a = {1,2}; System.out.println(a[5]); } }
  • 8. Declaring and allocation int intArray[]; //declaring array intArray = new int[20]; // allocating memory to array
  • 9. Example 6 public class Arrayxsample { public static void main(String[] args) { int a[] = new int[5]; System.out.println(a[3]); } }
  • 10. Example 7 public class Arrayxsample { public static void main(String[] args) { int [] a = new int [5]; a[0]=5; a [4]=1; System.out.println(a[4]); } }
  • 11. Example 8 public class Arrayxsample { public static void main(String[] args) { int [2] a = new int []; System.out.println(a[1]); } }
  • 12. Example 9 public class Arrayxsample { public static void main(String[] args) { int [2] a = int a []; System.out.println(a[1]); } }
  • 13. Example 10 public class Arrayxsample { public static void main(String[] args) { int [] a = new int [4]; System.out.println(a[5]); } }
  • 14. Example 11 public class Arrayxsample { public static void main(String[] args) { int [] a = new int [20]; for(int i =0;i<20;i++) { a[i]=i; } System.out.println(a[15]); } }
  • 15. Example 12 public class Arrayxsample { public static void main(String[] args) { int[] intArray = new int[]{ 1,2,3,4,5,6,7,8,9,10 }; System.out.println(intArray[5]); } }
  • 16. expand this public class Arrayxsample { public static void main(String[] args) { byte[] apple, orange, cake[]; int x,y[],z[]; } }
  • 17. Example 13 public class Arrayxsample { public static void main(String[] args) { int[] intArray = new int[]{ 1,2,3,4,5,6,7,8,9,10 }; System.out.println(intArray.length); } }
  • 18. Example 14 public class Arrayxsample { public static void main(String[] args) { int[][] intArray = {{1,2},{3,4,5}}; System.out.println(intArray[0][1]); System.out.println(intArray[1][0]); System.out.println(intArray[1][2]); } }
  • 19. Example 15 public class Arrayxsample { public static void main(String[] args) { int[][][] intArray = {{{1,2},{3,4}},{{5},{6,7,8}},{{9},{10,11,12}}}; System.out.println(intArray[0][1][0]); System.out.println(intArray[1][0][0]); System.out.println(intArray[2][1][2]); } }
  • 20. Example 16 public class Arrayxsample { public static void main(String[] args) { int i,j,k; int[][][] intArray = new int[100][100][100] ; for(i=0,j=0,k=0;(i>10 || j> 0 && k>0);i++,j=j+2,k++) { intArray[i][j][k]= (i+j)*k; } System.out.println(intArray[0][0][0]); } }
  • 21.
  • 22.