Submit Search
Upload
Upstate CSCI 200 Java Chapter 8 - Arrays
ā¢
Download as PPTX, PDF
ā¢
0 likes
ā¢
192 views
D
DanWooster1
Follow
Upstate CSCI 200 Java Chapter 8 - Arrays
Read less
Read more
Education
Report
Share
Report
Share
1 of 84
Download now
Recommended
Chapter 4 Writing Classes
Chapter 4 Writing Classes
DanWooster1
Ā
CSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook Slides
DanWooster1
Ā
Eo gaddis java_chapter_08_5e
Eo gaddis java_chapter_08_5e
Gina Bullock
Ā
Lesson 11 one dimensional array
Lesson 11 one dimensional array
MLG College of Learning, Inc
Ā
Cso gaddis java_chapter6
Cso gaddis java_chapter6
RhettB
Ā
Lecture 4 classes ii
Lecture 4 classes ii
the_wumberlog
Ā
Eo gaddis java_chapter_06_Classes and Objects
Eo gaddis java_chapter_06_Classes and Objects
Gina Bullock
Ā
Lect07
Lect07
Haitham El-Ghareeb
Ā
Recommended
Chapter 4 Writing Classes
Chapter 4 Writing Classes
DanWooster1
Ā
CSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook Slides
DanWooster1
Ā
Eo gaddis java_chapter_08_5e
Eo gaddis java_chapter_08_5e
Gina Bullock
Ā
Lesson 11 one dimensional array
Lesson 11 one dimensional array
MLG College of Learning, Inc
Ā
Cso gaddis java_chapter6
Cso gaddis java_chapter6
RhettB
Ā
Lecture 4 classes ii
Lecture 4 classes ii
the_wumberlog
Ā
Eo gaddis java_chapter_06_Classes and Objects
Eo gaddis java_chapter_06_Classes and Objects
Gina Bullock
Ā
Lect07
Lect07
Haitham El-Ghareeb
Ā
DSA-Lecture-05
DSA-Lecture-05
Haitham El-Ghareeb
Ā
Naive Bayes | Statistics
Naive Bayes | Statistics
Transweb Global Inc
Ā
Machine Learning - Supervised learning
Machine Learning - Supervised learning
Maneesha Caldera
Ā
DSA - Lecture 04
DSA - Lecture 04
Haitham El-Ghareeb
Ā
Binary search in ds
Binary search in ds
chauhankapil
Ā
Data strucutre basic introduction
Data strucutre basic introduction
manirajan12
Ā
Searching Techniques and Analysis
Searching Techniques and Analysis
AkashBorse2
Ā
Ap Power Point Chpt5
Ap Power Point Chpt5
dplunkett
Ā
Ap Power Point Chpt2
Ap Power Point Chpt2
dplunkett
Ā
Eo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5e
Gina Bullock
Ā
Data operatons & searching and sorting algorithms
Data operatons & searching and sorting algorithms
Anushdika Jeganathan
Ā
Dsa ā data structure and algorithms sorting
Dsa ā data structure and algorithms sorting
sajinis3
Ā
Abstract data types
Abstract data types
Hoang Nguyen
Ā
An Overview of NaĆÆve Bayes Classifier
An Overview of NaĆÆve Bayes Classifier
ananth
Ā
Machine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
Andrew Ferlitsch
Ā
Mahout part2
Mahout part2
Yasmine Gaber
Ā
Abstract Data Types
Abstract Data Types
karthikeyanC40
Ā
Arrays in java
Arrays in java
TharuniDiddekunta
Ā
pl12ch6.ppt
pl12ch6.ppt
BrandonGarcia294013
Ā
Variable
Variable
abdullah al mahamud rosi
Ā
Week06
Week06
hccit
Ā
Search Your DynamoDB Data with Amazon Elasticsearch Service (ANT302) - AWS re...
Search Your DynamoDB Data with Amazon Elasticsearch Service (ANT302) - AWS re...
Amazon Web Services
Ā
More Related Content
What's hot
DSA-Lecture-05
DSA-Lecture-05
Haitham El-Ghareeb
Ā
Naive Bayes | Statistics
Naive Bayes | Statistics
Transweb Global Inc
Ā
Machine Learning - Supervised learning
Machine Learning - Supervised learning
Maneesha Caldera
Ā
DSA - Lecture 04
DSA - Lecture 04
Haitham El-Ghareeb
Ā
Binary search in ds
Binary search in ds
chauhankapil
Ā
Data strucutre basic introduction
Data strucutre basic introduction
manirajan12
Ā
Searching Techniques and Analysis
Searching Techniques and Analysis
AkashBorse2
Ā
Ap Power Point Chpt5
Ap Power Point Chpt5
dplunkett
Ā
Ap Power Point Chpt2
Ap Power Point Chpt2
dplunkett
Ā
Eo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5e
Gina Bullock
Ā
Data operatons & searching and sorting algorithms
Data operatons & searching and sorting algorithms
Anushdika Jeganathan
Ā
Dsa ā data structure and algorithms sorting
Dsa ā data structure and algorithms sorting
sajinis3
Ā
Abstract data types
Abstract data types
Hoang Nguyen
Ā
An Overview of NaĆÆve Bayes Classifier
An Overview of NaĆÆve Bayes Classifier
ananth
Ā
Machine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
Andrew Ferlitsch
Ā
Mahout part2
Mahout part2
Yasmine Gaber
Ā
Abstract Data Types
Abstract Data Types
karthikeyanC40
Ā
Arrays in java
Arrays in java
TharuniDiddekunta
Ā
What's hot
(18)
DSA-Lecture-05
DSA-Lecture-05
Ā
Naive Bayes | Statistics
Naive Bayes | Statistics
Ā
Machine Learning - Supervised learning
Machine Learning - Supervised learning
Ā
DSA - Lecture 04
DSA - Lecture 04
Ā
Binary search in ds
Binary search in ds
Ā
Data strucutre basic introduction
Data strucutre basic introduction
Ā
Searching Techniques and Analysis
Searching Techniques and Analysis
Ā
Ap Power Point Chpt5
Ap Power Point Chpt5
Ā
Ap Power Point Chpt2
Ap Power Point Chpt2
Ā
Eo gaddis java_chapter_09_5e
Eo gaddis java_chapter_09_5e
Ā
Data operatons & searching and sorting algorithms
Data operatons & searching and sorting algorithms
Ā
Dsa ā data structure and algorithms sorting
Dsa ā data structure and algorithms sorting
Ā
Abstract data types
Abstract data types
Ā
An Overview of NaĆÆve Bayes Classifier
An Overview of NaĆÆve Bayes Classifier
Ā
Machine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
Ā
Mahout part2
Mahout part2
Ā
Abstract Data Types
Abstract Data Types
Ā
Arrays in java
Arrays in java
Ā
Similar to Upstate CSCI 200 Java Chapter 8 - Arrays
pl12ch6.ppt
pl12ch6.ppt
BrandonGarcia294013
Ā
Variable
Variable
abdullah al mahamud rosi
Ā
Week06
Week06
hccit
Ā
Search Your DynamoDB Data with Amazon Elasticsearch Service (ANT302) - AWS re...
Search Your DynamoDB Data with Amazon Elasticsearch Service (ANT302) - AWS re...
Amazon Web Services
Ā
Apex code (Salesforce)
Apex code (Salesforce)
Mohammed Safwat Abu Kwaik
Ā
Cso gaddis java_chapter8
Cso gaddis java_chapter8
mlrbrown
Ā
Unit 1 array based implementation
Unit 1 array based implementation
LavanyaJ28
Ā
Generics Collections
Generics Collections
phanleson
Ā
Generics collections
Generics collections
Yaswanth Babu Gummadivelli
Ā
Week02
Week02
hccit
Ā
CSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using Classes
DanWooster1
Ā
Data structures in c#
Data structures in c#
SivaSankar Gorantla
Ā
9781337102087 ppt ch08
9781337102087 ppt ch08
Terry Yoast
Ā
Array in C# 3.5
Array in C# 3.5
Gopal Ji Singh
Ā
Learning core java
Learning core java
Abhay Bharti
Ā
Searching Your Data with Amazon Elasticsearch Service (ANT384) - AWS re:Inven...
Searching Your Data with Amazon Elasticsearch Service (ANT384) - AWS re:Inven...
Amazon Web Services
Ā
Arrays
Arrays
ViniVini48
Ā
ppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptx
AmanRai352102
Ā
L9 wrapper classes
L9 wrapper classes
teach4uin
Ā
java.pdf
java.pdf
RAJCHATTERJEE24
Ā
Similar to Upstate CSCI 200 Java Chapter 8 - Arrays
(20)
pl12ch6.ppt
pl12ch6.ppt
Ā
Variable
Variable
Ā
Week06
Week06
Ā
Search Your DynamoDB Data with Amazon Elasticsearch Service (ANT302) - AWS re...
Search Your DynamoDB Data with Amazon Elasticsearch Service (ANT302) - AWS re...
Ā
Apex code (Salesforce)
Apex code (Salesforce)
Ā
Cso gaddis java_chapter8
Cso gaddis java_chapter8
Ā
Unit 1 array based implementation
Unit 1 array based implementation
Ā
Generics Collections
Generics Collections
Ā
Generics collections
Generics collections
Ā
Week02
Week02
Ā
CSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using Classes
Ā
Data structures in c#
Data structures in c#
Ā
9781337102087 ppt ch08
9781337102087 ppt ch08
Ā
Array in C# 3.5
Array in C# 3.5
Ā
Learning core java
Learning core java
Ā
Searching Your Data with Amazon Elasticsearch Service (ANT384) - AWS re:Inven...
Searching Your Data with Amazon Elasticsearch Service (ANT384) - AWS re:Inven...
Ā
Arrays
Arrays
Ā
ppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptx
Ā
L9 wrapper classes
L9 wrapper classes
Ā
java.pdf
java.pdf
Ā
More from DanWooster1
Upstate CSCI 540 Agile Development
Upstate CSCI 540 Agile Development
DanWooster1
Ā
Upstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testing
DanWooster1
Ā
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9
DanWooster1
Ā
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
Ā
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
Ā
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3
DanWooster1
Ā
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2
DanWooster1
Ā
Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1
DanWooster1
Ā
Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3
DanWooster1
Ā
Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2
DanWooster1
Ā
Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1
DanWooster1
Ā
Upstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOP
DanWooster1
Ā
CSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & Expressions
DanWooster1
Ā
CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01
DanWooster1
Ā
Chapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loops
DanWooster1
Ā
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
DanWooster1
Ā
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
DanWooster1
Ā
Upstate CSCI 450 PHP
Upstate CSCI 450 PHP
DanWooster1
Ā
CSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - Classes
DanWooster1
Ā
C++ Chapter 11 OOP - Part 7
C++ Chapter 11 OOP - Part 7
DanWooster1
Ā
More from DanWooster1
(20)
Upstate CSCI 540 Agile Development
Upstate CSCI 540 Agile Development
Ā
Upstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testing
Ā
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9
Ā
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
Ā
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
Ā
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3
Ā
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2
Ā
Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1
Ā
Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3
Ā
Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2
Ā
Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1
Ā
Upstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOP
Ā
CSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & Expressions
Ā
CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01
Ā
Chapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loops
Ā
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
Ā
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
Ā
Upstate CSCI 450 PHP
Upstate CSCI 450 PHP
Ā
CSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - Classes
Ā
C++ Chapter 11 OOP - Part 7
C++ Chapter 11 OOP - Part 7
Ā
Recently uploaded
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
InMediaRes1
Ā
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
JemimahLaneBuaron
Ā
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
RKavithamani
Ā
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Celine George
Ā
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
EduSkills OECD
Ā
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
sanyamsingh5019
Ā
Model Call Girl in Bikash Puri Delhi reach out to us at š9953056974š
Model Call Girl in Bikash Puri Delhi reach out to us at š9953056974š
9953056974 Low Rate Call Girls In Saket, Delhi NCR
Ā
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
GaneshChakor2
Ā
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
SafetyChain Software
Ā
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
Ā
microwave assisted reaction. General introduction
microwave assisted reaction. General introduction
Maksud Ahmed
Ā
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
KarinaGenton
Ā
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
ChitralekhaTherkar
Ā
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
Celine George
Ā
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
FatimaKhan178732
Ā
18-04-UA_REPORT_MEDIALITERAŠ”Y_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAŠ”Y_INDEX-DM_23-1-final-eng.pdf
ssuser54595a
Ā
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
Ā
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
UmakantAnnand
Ā
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
manuelaromero2013
Ā
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
eniolaolutunde
Ā
Recently uploaded
(20)
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
Ā
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
Ā
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Ā
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Ā
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Ā
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
Ā
Model Call Girl in Bikash Puri Delhi reach out to us at š9953056974š
Model Call Girl in Bikash Puri Delhi reach out to us at š9953056974š
Ā
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
Ā
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
Ā
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Ā
microwave assisted reaction. General introduction
microwave assisted reaction. General introduction
Ā
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
Ā
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
Ā
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
Ā
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
Ā
18-04-UA_REPORT_MEDIALITERAŠ”Y_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAŠ”Y_INDEX-DM_23-1-final-eng.pdf
Ā
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
Ā
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
Ā
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
Ā
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
Ā
Upstate CSCI 200 Java Chapter 8 - Arrays
1.
Javaā¢ Software Solutions:
Foundations of Program Design Ninth Edition Chapter 8 Arrays Copyright Ā© 2018 Pearson Education, Inc. All Rights Reserved
2.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays (1 of 7) ā¢ Arrays are objects that help us organize large amounts of information ā¢ Chapter 8 focuses on: ā array declaration and use ā bounds checking and capacity ā arrays that store object references ā variable length parameter lists ā multidimensional arrays
3.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Outline (1 of 7) ā¢ Declaring and Using Arrays ā¢ Arrays of Objects ā¢ Variable Length Parameter Lists ā¢ Two-Dimensional Arrays
4.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays (2 of 7) ā¢ The ArrayList class, introduced in Chapter 5, is used to organize a list of objects ā¢ It is a class in the Java API ā¢ An array is a programming language construct used to organize a list of objects ā¢ It has special syntax to access elements ā¢ As its name implies, the ArrayList class uses an array internally to manage the list of objects
5.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays (3 of 7) ā¢ An array is an ordered list of values:
6.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays (4 of 7) ā¢ A particular value in an array is referenced using the array name followed by the index in brackets ā¢ For example, the expression refers to the value 94 (the 3rd value in the array) ā¢ That expression represents a place to store a single integer and can be used wherever an integer variable can be used
7.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays (5 of 7) ā¢ For example, an array element can be assigned a value, printed, or used in a calculation:
8.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays (6 of 7) ā¢ The values held in an array are called array elements ā¢ An array stores multiple values of the same type - the element type ā¢ The element type can be a primitive type or an object reference ā¢ Therefore, we can create an array of integers, an array of characters, an array of String objects, an array of Coin objects, etc.
9.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays (7 of 7) ā¢ In Java, the array itself is an object that must be instantiated ā¢ Another way to depict the scores array:
10.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Declaring Arrays (1 of 2) ā¢ The scores array could be declared as follows: ā¢ The type of the variable scores is int[] (an array of integers) ā¢ Note that the array type does not specify its size, but each object of that type has a specific size ā¢ The reference variable scores is set to a new array object that can hold 10 integers
11.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Declaring Arrays (2 of 2) ā¢ Some other examples of array declarations:
12.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Using Arrays ā¢ The for-each version of the for loop can be used when processing array elements: ā¢ This is only appropriate when processing all array elements starting at index 0 ā¢ It canāt be used to set the array values ā¢ See BasicArray.java
13.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.1 (1 of 2)
14.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.1 (2 of 2)
15.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Basic Array Example
16.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Quick Check 1 (1 of 2) Write an array declaration to represent the ages of 100 children. Write code that prints each value in an array of integers named values.
17.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Quick Check 1 (2 of 2) Write an array declaration to represent the ages of 100 children. Write code that prints each value in an array of integers named values.
18.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Bounds Checking (1 of 3) ā¢ Once an array is created, it has a fixed size ā¢ An index used in an array reference must specify a valid element ā¢ That is, the index value must be in range 0 to Nā1 ā¢ The Java interpreter throws an ArrayIndexOutOfBoundsException if an array index is out of bounds ā¢ This is called automatic bounds checking
19.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Bounds Checking (2 of 3) ā¢ For example, if the array codes can hold 100 values, it can be indexed from 0 to 99 ā¢ If the value of count is 100, then the following reference will cause an exception to be thrown: ā¢ Itās common to introduce off-by-one errors when using arrays:
20.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Bounds Checking (3 of 3) ā¢ Each array object has a public constant called length that stores the size of the array ā¢ It is referenced using the array name: ā¢ Note that length holds the number of elements, not the largest index ā¢ See ReverseOrder.java ā¢ See LetterCount.java
21.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.2 (1 of 3)
22.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.2 (2 of 3)
23.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.2 (3 of 3)
24.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.3 (1 of 4)
25.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.3 (2 of 4)
26.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.3 (3 of 4)
27.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.3 (4 of 4)
28.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Alternate Array Syntax ā¢ The brackets of the array type can be associated with the element type or with the name of the array ā¢ Therefore the following two declarations are equivalent: ā¢ The first format generally is more readable and should be used
29.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Initializer Lists (1 of 2) ā¢ An initializer list can be used to instantiate and fill an array in one step ā¢ The values are delimited by braces and separated by commas ā¢ Examples:
30.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Initializer Lists (2 of 2) ā¢ Note that when an initializer list is used: ā the new operator is not used ā no size value is specified ā¢ The size of the array is determined by the number of items in the list ā¢ An initializer list can be used only in the array declaration ā¢ See Primes.java
31.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.4 (1 of 2)
32.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.4 (2 of 2)
33.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays as Parameters ā¢ An entire array can be passed as a parameter to a method ā¢ Like any other object, the reference to the array is passed, making the formal and actual parameters aliases of each other ā¢ Therefore, changing an array element within the method changes the original ā¢ An individual array element can be passed to a method as well, in which case the type of the formal parameter is the same as the element type
34.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Outline (2 of 7) ā¢ Declaring and Using Arrays ā¢ Arrays of Objects ā¢ Variable Length Parameter Lists ā¢ Two-Dimensional Arrays
35.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays of Objects (1 of 7) ā¢ The elements of an array can be object references ā¢ The following declaration reserves space to store 5 references to String objects ā¢ It does NOT create the String objects themselves ā¢ Initially an array of objects holds null references ā¢ Each object stored in an array must be instantiated separately
36.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays of Objects (2 of 7) ā¢ The words array when initially declared: ā¢ At this point, the following line of code would throw a NullPointerException:
37.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays of Objects (3 of 7) ā¢ After some String objects are created and stored in the array:
38.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays of Objects (4 of 7) ā¢ Keep in mind that String objects can be created using literals ā¢ The following declaration creates an array object called verbs and fills it with four String objects created using string literals
39.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays of Objects (5 of 7) ā¢ The following example creates an array of Grade objects, each with a string representation and a numeric lower bound ā¢ The letter grades include plus and minus designations, so must be stored as strings instead of char ā¢ See GradeRange.java ā¢ See Grade.java
40.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.5 (1 of 2)
41.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.5 (2 of 2)
42.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.6 (1 of 3)
43.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.6 (2 of 3)
44.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.6 (3 of 3)
45.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays of Objects (6 of 7) ā¢ Now letās look at an example that manages a collection of DVD objects ā¢ An initial capacity of 100 is created for the collection ā¢ If more room is needed, a private method is used to create a larger array and transfer the current DVDs ā¢ See Movies.java ā¢ See DVDCollection.java ā¢ See DVD.java
46.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.7 (1 of 3)
47.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.7 (2 of 3)
48.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.7 (3 of 3)
49.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.8 (1 of 4)
50.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.8 (2 of 4)
51.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.8 (3 of 4)
52.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.8 (4 of 4)
53.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.9 (1 of 2)
54.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.9 (2 of 2)
55.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Arrays of Objects (7 of 7) ā¢ A UML diagram for the Movies program:
56.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Command-Line Arguments ā¢ The signature of the main method indicates that it takes an array of String objects as a parameter ā¢ These values come from command-line arguments that are provided when the interpreter is invoked ā¢ For example, the following invocation of the interpreter passes three String objects into the main method of the StateEval program: ā¢ See NameTag.java
57.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.10 (1 of 2)
58.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.10 (2 of 2)
59.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Outline (3 of 7) ā¢ Declaring and Using Arrays ā¢ Arrays of Objects ā¢ Variable Length Parameter Lists ā¢ Two-Dimensional Arrays
60.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Variable Length Parameter Lists (1 of 7) ā¢ Suppose we wanted to create a method that processed a different amount of data from one invocation to the next ā¢ For example, letās define a method called average that returns the average of a set of integer parameters
61.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Variable Length Parameter Lists (2 of 7) ā¢ We could define overloaded versions of the average method ā Downside: weād need a separate version of the method for each additional parameter ā¢ We could define the method to accept an array of integers ā Downside: weād have to create the array and store the integers prior to calling the method each time ā¢ Instead, Java provides a convenient way to create variable length parameter lists
62.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Variable Length Parameter Lists (3 of 7) ā¢ Using special syntax in the formal parameter list, we can define a method to accept any number of parameters of the same type ā¢ For each call, the parameters are automatically put into an array for easy processing in the method
63.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Variable Length Parameter Lists (4 of 7)
64.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Variable Length Parameter Lists (5 of 7) ā¢ The type of the parameter can be any primitive or object type:
65.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Quick Check 2 (1 of 2) Write method called distance that accepts a variable number of integers (which each represent the distance of one leg of a trip) and returns the total distance of the trip.
66.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Quick Check 2 (2 of 2) Write method called distance that accepts a variable number of integers (which each represent the distance of one leg of a trip) and returns the total distance of the trip.
67.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Variable Length Parameter Lists (6 of 7) ā¢ A method that accepts a variable number of parameters can also accept other parameters ā¢ The following method accepts an int, a String object, and a variable number of double values into an array called nums
68.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Variable Length Parameter Lists (7 of 7) ā¢ The varying number of parameters must come last in the formal arguments ā¢ A method cannot accept two sets of varying parameters ā¢ Constructors can also be set up to accept a variable number of parameters ā¢ See VariableParameters.java ā¢ See Family.java
69.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.11 (1 of 2)
70.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.11 (2 of 2)
71.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.12 (1 of 2)
72.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.12 (2 of 2)
73.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Outline (4 of 7) ā¢ Declaring and Using Arrays ā¢ Arrays of Objects ā¢ Variable Length Parameter Lists ā¢ Two-Dimensional Arrays
74.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Two-Dimensional Arrays (1 of 3) ā¢ A one-dimensional array stores a list of elements ā¢ A two-dimensional array can be thought of as a table of elements, with rows and columns
75.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Two-Dimensional Arrays (2 of 3) ā¢ To be precise, in Java a two-dimensional array is an array of arrays ā¢ A two-dimensional array is declared by specifying the size of each dimension separately: ā¢ A array element is referenced using two index values: ā¢ The array stored in one row can be specified using one index
76.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Two-Dimensional Arrays (3 of 3) Expression Type Description table Computer code reads, i n t left bracket right bracket left bracket right bracket 2D array of integers, or array of integer arrays table[5] Computer code reads, i n t left bracket right bracket array of integers table[5][12] Computer code reads, i n t Integer int[][] int[] int ā¢ See TwoDArray.java ā¢ See SodaSurvey.java
77.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.13 (1 of 2)
78.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.13 (2 of 2)
79.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.14 (1 of 3)
80.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.14 (2 of 3)
81.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Listing 8.14 (3 of 3)
82.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Multidimensional Arrays ā¢ An array can have many dimensions - if it has more than one dimension, it is called a multidimensional array ā¢ Each dimension subdivides the previous one into the specified number of elements ā¢ Each dimension has its own length constant ā¢ Because each dimension is an array of array references, the arrays within one dimension can be of different lengths ā these are sometimes called ragged arrays
83.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Summary ā¢ Chapter 8 has focused on: ā array declaration and use ā bounds checking and capacity ā arrays that store object references ā variable length parameter lists ā multidimensional arrays
84.
Copyright Ā© 2018
Pearson Education, Inc. All Rights Reserved Copyright This work is protected by United States copyright laws and is provided solely for the use of instructors in teaching their courses and assessing student learning. Dissemination or sale of any part of this work (including on the World Wide Web) will destroy the integrity of the work and is not permitted. The work and materials from it should never be made available to students except by instructors using the accompanying text in their classes. All recipients of this work are expected to abide by these restrictions and to honor the intended pedagogical purposes and the needs of other instructors who rely on these materials.
Editor's Notes
If this PowerPoint presentation contains mathematical equations, you may need to check that your computer has the following installed: 1) MathType Plugin 2) Math Player (free versions available) 3) NVDA Reader (free versions available)
Download now