SlideShare a Scribd company logo
List and Iterator
List Interface
• Java has 3 classes which implement the List
Interface - LinkedList, ArrayList and Vector.
• How do you use the ArrayList in your
program?
• import java.util.*
• How to create a List object?
• List lst = new ArrayList();
• Can we do this? Why?
• List lst = new List();
• How to output the List object?
• With the List object, we don’t need to use
loop structure to print out each element,
simply output the List object. Only the output
will be surrounded by square brackets.
• Name some of the List methods.
• boolean isEmpty()
• int size()
• Object set(int index, Object o)
• void add(int index, Object o)
• boolean add(Object o)
• Iterator<E> iterator()
• Do we need to cast the element retrieved
from a list object?
• Yes, unless the list object was created using
type parameters, meaning?
• List doubleList = new ArrayList();
• /* fill in the Arraylist with some Double objects */
• Double aDouble = doubleList.get(0); => ok?
• List<Double> doubleList = new ArrayList<Double>();
List Interface
• List interface. What is an interface? P135
1) All methods in the interface are both public
and abstract.
2) Any class implementing the interface has to
implement every method, otherwise…
• More rule on p139.
Iterator
• What is Iteration?
• Iteration is a continual repeating of
something.
• What java structure fits this description?
• Loops are iteration structure
• What is an iterator?
• An iterator’a sole purpose is to traverse a
collection, one element at a time.
• Is Iterator a class?
• NO, it is an interface.
• What are the 3 methods of the Iterator?
• boolean hasNext(); E next(); void remove()
• How to use a generic iterator?
• List<String> list = new ArrayList<String>();
<code to initialize list with strings>
Iterator<String> itr = list.iterator();
while(itr.hasNext())
System.out.println(itr.next())
• What is above while loop equivalent to?
• for-each loop
practice
• Write down the answers on the paper.
• Write a generic List object of Integer.
• Get an iterator from the List object.
• Loop through the list and if the number is not
mutiples of 3, remove it.
What is wrong with the codes?
Iterator<someType) itr = list.iterator();
while(true)
System.out.println(itr.next());
Iterator<someType) itr = list.iterator();
someType ob= itr.next();
itr.remove();
itr.remove();
• What is the different to use iterator from for-
each loop
• Use a for-each loop for accessing and
modifying objects in a list. Use an iterator for
removal of objects.
Homework
• Read Barron’s chapter 7 and BPJ lesson 40
about recursion. Write down any notes that
you think are important. They can be in any
form like questions and answers, or simply
questions which you don’t understand.
Everyone has to submit at least 25 notes or
remarks.

More Related Content

What's hot

Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
swati kushwaha
 
Unit 4
Unit 4Unit 4
data structures and algorithms Unit 1
data structures and algorithms Unit 1data structures and algorithms Unit 1
data structures and algorithms Unit 1
infanciaj
 
Es6 day3
Es6 day3Es6 day3
Es6 day3
Abhishek Sharma
 
Python data type
Python data typePython data type
Python data type
nuripatidar
 
Python l3
Python l3Python l3
Python list functions
Python list functionsPython list functions
Python list functions
Aishwarya Deshmukh
 
List Manipulation in FME
List Manipulation in FMEList Manipulation in FME
List Manipulation in FME
Safe Software
 
Programming with Python - Week 3
Programming with Python - Week 3Programming with Python - Week 3
Programming with Python - Week 3
Ahmet Bulut
 
lists
listslists
lists
Rajendran
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
MansiSuthar3
 
Data Structure lec#2
Data Structure lec#2Data Structure lec#2
Data Structure lec#2
University of Gujrat, Pakistan
 
Programming with Python - Week 2
Programming with Python - Week 2Programming with Python - Week 2
Programming with Python - Week 2
Ahmet Bulut
 
Intro to Lists
Intro to ListsIntro to Lists
Intro to Lists
primeteacher32
 
The awesome algorithm
The awesome algorithmThe awesome algorithm
The awesome algorithm
Sazzad Hossain
 
Java Tutorial Lab 7
Java Tutorial Lab 7Java Tutorial Lab 7
Java Tutorial Lab 7
Berk Soysal
 

What's hot (16)

Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
 
Unit 4
Unit 4Unit 4
Unit 4
 
data structures and algorithms Unit 1
data structures and algorithms Unit 1data structures and algorithms Unit 1
data structures and algorithms Unit 1
 
Es6 day3
Es6 day3Es6 day3
Es6 day3
 
Python data type
Python data typePython data type
Python data type
 
Python l3
Python l3Python l3
Python l3
 
Python list functions
Python list functionsPython list functions
Python list functions
 
List Manipulation in FME
List Manipulation in FMEList Manipulation in FME
List Manipulation in FME
 
Programming with Python - Week 3
Programming with Python - Week 3Programming with Python - Week 3
Programming with Python - Week 3
 
lists
listslists
lists
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Data Structure lec#2
Data Structure lec#2Data Structure lec#2
Data Structure lec#2
 
Programming with Python - Week 2
Programming with Python - Week 2Programming with Python - Week 2
Programming with Python - Week 2
 
Intro to Lists
Intro to ListsIntro to Lists
Intro to Lists
 
The awesome algorithm
The awesome algorithmThe awesome algorithm
The awesome algorithm
 
Java Tutorial Lab 7
Java Tutorial Lab 7Java Tutorial Lab 7
Java Tutorial Lab 7
 

Viewers also liked

Linked list
Linked listLinked list
Linked list
Fraboni Ec
 
Computer security
Computer securityComputer security
Computer security
Fraboni Ec
 
Data and assessment
Data and assessmentData and assessment
Data and assessment
Fraboni Ec
 
Python data structures
Python data structuresPython data structures
Python data structures
Fraboni Ec
 
Information retrieval
Information retrievalInformation retrieval
Information retrieval
Fraboni Ec
 
Crypto passport authentication
Crypto passport authenticationCrypto passport authentication
Crypto passport authentication
Fraboni Ec
 
Xml schema
Xml schemaXml schema
Xml schema
Fraboni Ec
 
Java
JavaJava
Prolog programming
Prolog programmingProlog programming
Prolog programming
Fraboni Ec
 
Building a-database
Building a-databaseBuilding a-database
Building a-database
Fraboni Ec
 
Learn ruby intro
Learn ruby introLearn ruby intro
Learn ruby intro
Fraboni Ec
 
Hash crypto
Hash cryptoHash crypto
Hash crypto
Fraboni Ec
 
coupe-du-monde-package_fecafoot
coupe-du-monde-package_fecafootcoupe-du-monde-package_fecafoot
coupe-du-monde-package_fecafootFatime Karagama
 
My netral
My netralMy netral
My netral
Fahmi Amrizal
 
Exception
ExceptionException
Exception
Fraboni Ec
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
Fraboni Ec
 
Test driven development
Test driven developmentTest driven development
Test driven development
Fraboni Ec
 
Nlp naive bayes
Nlp naive bayesNlp naive bayes
Nlp naive bayes
Fraboni Ec
 
Reflection
ReflectionReflection
Reflection
Fraboni Ec
 
Stack queue
Stack queueStack queue
Stack queue
Fraboni Ec
 

Viewers also liked (20)

Linked list
Linked listLinked list
Linked list
 
Computer security
Computer securityComputer security
Computer security
 
Data and assessment
Data and assessmentData and assessment
Data and assessment
 
Python data structures
Python data structuresPython data structures
Python data structures
 
Information retrieval
Information retrievalInformation retrieval
Information retrieval
 
Crypto passport authentication
Crypto passport authenticationCrypto passport authentication
Crypto passport authentication
 
Xml schema
Xml schemaXml schema
Xml schema
 
Java
JavaJava
Java
 
Prolog programming
Prolog programmingProlog programming
Prolog programming
 
Building a-database
Building a-databaseBuilding a-database
Building a-database
 
Learn ruby intro
Learn ruby introLearn ruby intro
Learn ruby intro
 
Hash crypto
Hash cryptoHash crypto
Hash crypto
 
coupe-du-monde-package_fecafoot
coupe-du-monde-package_fecafootcoupe-du-monde-package_fecafoot
coupe-du-monde-package_fecafoot
 
My netral
My netralMy netral
My netral
 
Exception
ExceptionException
Exception
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Nlp naive bayes
Nlp naive bayesNlp naive bayes
Nlp naive bayes
 
Reflection
ReflectionReflection
Reflection
 
Stack queue
Stack queueStack queue
Stack queue
 

Similar to List and iterator

STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
Java class 5
Java class 5Java class 5
Java class 5
Edureka!
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptx
ASRPANDEY
 
collection framework.pptx
collection framework.pptxcollection framework.pptx
collection framework.pptx
SoniaKapoor56
 
tupple.pptx
tupple.pptxtupple.pptx
tupple.pptx
satyabratPanda2
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
channa basava
 
Java10 Collections and Information
Java10 Collections and InformationJava10 Collections and Information
Java10 Collections and Information
SoftNutx
 
A2003822018_21789_17_2018_09. ArrayList.ppt
A2003822018_21789_17_2018_09. ArrayList.pptA2003822018_21789_17_2018_09. ArrayList.ppt
A2003822018_21789_17_2018_09. ArrayList.ppt
RithwikRanjan
 
javacollections.pdf
javacollections.pdfjavacollections.pdf
javacollections.pdf
ManojKandhasamy1
 
L11 array list
L11 array listL11 array list
L11 array list
teach4uin
 
F# array searching
F#  array searchingF#  array searching
F# array searching
DrRajeshreeKhande
 
Lists
ListsLists
Collections Training
Collections TrainingCollections Training
Collections Training
Ramindu Deshapriya
 
ArrayList class and useful methods.pptx
ArrayList class and useful methods.pptxArrayList class and useful methods.pptx
ArrayList class and useful methods.pptx
Abid523408
 
lecture 02.2.ppt
lecture 02.2.pptlecture 02.2.ppt
lecture 02.2.ppt
NathanielAdika
 
Python Basics it will teach you about data types
Python Basics it will teach you about data typesPython Basics it will teach you about data types
Python Basics it will teach you about data types
NimitSinghal2
 
Collection Framework-1.pptx
Collection Framework-1.pptxCollection Framework-1.pptx
Collection Framework-1.pptx
SarthakSrivastava70
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementation
LavanyaJ28
 
Python programming
Python programmingPython programming
Python programming
sirikeshava
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
Muthukumaran Subramanian
 

Similar to List and iterator (20)

STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
STRINGS IN JAVA
 
Java class 5
Java class 5Java class 5
Java class 5
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptx
 
collection framework.pptx
collection framework.pptxcollection framework.pptx
collection framework.pptx
 
tupple.pptx
tupple.pptxtupple.pptx
tupple.pptx
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
 
Java10 Collections and Information
Java10 Collections and InformationJava10 Collections and Information
Java10 Collections and Information
 
A2003822018_21789_17_2018_09. ArrayList.ppt
A2003822018_21789_17_2018_09. ArrayList.pptA2003822018_21789_17_2018_09. ArrayList.ppt
A2003822018_21789_17_2018_09. ArrayList.ppt
 
javacollections.pdf
javacollections.pdfjavacollections.pdf
javacollections.pdf
 
L11 array list
L11 array listL11 array list
L11 array list
 
F# array searching
F#  array searchingF#  array searching
F# array searching
 
Lists
ListsLists
Lists
 
Collections Training
Collections TrainingCollections Training
Collections Training
 
ArrayList class and useful methods.pptx
ArrayList class and useful methods.pptxArrayList class and useful methods.pptx
ArrayList class and useful methods.pptx
 
lecture 02.2.ppt
lecture 02.2.pptlecture 02.2.ppt
lecture 02.2.ppt
 
Python Basics it will teach you about data types
Python Basics it will teach you about data typesPython Basics it will teach you about data types
Python Basics it will teach you about data types
 
Collection Framework-1.pptx
Collection Framework-1.pptxCollection Framework-1.pptx
Collection Framework-1.pptx
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementation
 
Python programming
Python programmingPython programming
Python programming
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
 

More from Fraboni Ec

Hardware multithreading
Hardware multithreadingHardware multithreading
Hardware multithreading
Fraboni Ec
 
Lisp
LispLisp
What is simultaneous multithreading
What is simultaneous multithreadingWhat is simultaneous multithreading
What is simultaneous multithreading
Fraboni Ec
 
Directory based cache coherence
Directory based cache coherenceDirectory based cache coherence
Directory based cache coherence
Fraboni Ec
 
Business analytics and data mining
Business analytics and data miningBusiness analytics and data mining
Business analytics and data mining
Fraboni Ec
 
Big picture of data mining
Big picture of data miningBig picture of data mining
Big picture of data mining
Fraboni Ec
 
Data mining and knowledge discovery
Data mining and knowledge discoveryData mining and knowledge discovery
Data mining and knowledge discovery
Fraboni Ec
 
Cache recap
Cache recapCache recap
Cache recap
Fraboni Ec
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Fraboni Ec
 
Hardware managed cache
Hardware managed cacheHardware managed cache
Hardware managed cache
Fraboni Ec
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Fraboni Ec
 
Cobol, lisp, and python
Cobol, lisp, and pythonCobol, lisp, and python
Cobol, lisp, and python
Fraboni Ec
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
Fraboni Ec
 
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsOptimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessors
Fraboni Ec
 
Abstraction file
Abstraction fileAbstraction file
Abstraction file
Fraboni Ec
 
Object model
Object modelObject model
Object model
Fraboni Ec
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
Fraboni Ec
 
Abstract class
Abstract classAbstract class
Abstract class
Fraboni Ec
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
Fraboni Ec
 
Inheritance
InheritanceInheritance
Inheritance
Fraboni Ec
 

More from Fraboni Ec (20)

Hardware multithreading
Hardware multithreadingHardware multithreading
Hardware multithreading
 
Lisp
LispLisp
Lisp
 
What is simultaneous multithreading
What is simultaneous multithreadingWhat is simultaneous multithreading
What is simultaneous multithreading
 
Directory based cache coherence
Directory based cache coherenceDirectory based cache coherence
Directory based cache coherence
 
Business analytics and data mining
Business analytics and data miningBusiness analytics and data mining
Business analytics and data mining
 
Big picture of data mining
Big picture of data miningBig picture of data mining
Big picture of data mining
 
Data mining and knowledge discovery
Data mining and knowledge discoveryData mining and knowledge discovery
Data mining and knowledge discovery
 
Cache recap
Cache recapCache recap
Cache recap
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
Hardware managed cache
Hardware managed cacheHardware managed cache
Hardware managed cache
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Cobol, lisp, and python
Cobol, lisp, and pythonCobol, lisp, and python
Cobol, lisp, and python
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsOptimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessors
 
Abstraction file
Abstraction fileAbstraction file
Abstraction file
 
Object model
Object modelObject model
Object model
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Abstract class
Abstract classAbstract class
Abstract class
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
 
Inheritance
InheritanceInheritance
Inheritance
 

Recently uploaded

"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
HarpalGohil4
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
ScyllaDB
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
Sunil Jagani
 
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
AlexanderRichford
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
UiPathCommunity
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 

Recently uploaded (20)

"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
 
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 

List and iterator

  • 2. List Interface • Java has 3 classes which implement the List Interface - LinkedList, ArrayList and Vector. • How do you use the ArrayList in your program? • import java.util.* • How to create a List object? • List lst = new ArrayList(); • Can we do this? Why? • List lst = new List();
  • 3. • How to output the List object? • With the List object, we don’t need to use loop structure to print out each element, simply output the List object. Only the output will be surrounded by square brackets. • Name some of the List methods. • boolean isEmpty() • int size() • Object set(int index, Object o) • void add(int index, Object o) • boolean add(Object o) • Iterator<E> iterator()
  • 4. • Do we need to cast the element retrieved from a list object? • Yes, unless the list object was created using type parameters, meaning? • List doubleList = new ArrayList(); • /* fill in the Arraylist with some Double objects */ • Double aDouble = doubleList.get(0); => ok? • List<Double> doubleList = new ArrayList<Double>();
  • 5. List Interface • List interface. What is an interface? P135 1) All methods in the interface are both public and abstract. 2) Any class implementing the interface has to implement every method, otherwise… • More rule on p139.
  • 6. Iterator • What is Iteration? • Iteration is a continual repeating of something. • What java structure fits this description? • Loops are iteration structure • What is an iterator? • An iterator’a sole purpose is to traverse a collection, one element at a time. • Is Iterator a class? • NO, it is an interface.
  • 7. • What are the 3 methods of the Iterator? • boolean hasNext(); E next(); void remove() • How to use a generic iterator? • List<String> list = new ArrayList<String>(); <code to initialize list with strings> Iterator<String> itr = list.iterator(); while(itr.hasNext()) System.out.println(itr.next()) • What is above while loop equivalent to? • for-each loop
  • 8. practice • Write down the answers on the paper. • Write a generic List object of Integer. • Get an iterator from the List object. • Loop through the list and if the number is not mutiples of 3, remove it.
  • 9. What is wrong with the codes? Iterator<someType) itr = list.iterator(); while(true) System.out.println(itr.next()); Iterator<someType) itr = list.iterator(); someType ob= itr.next(); itr.remove(); itr.remove();
  • 10. • What is the different to use iterator from for- each loop • Use a for-each loop for accessing and modifying objects in a list. Use an iterator for removal of objects.
  • 11. Homework • Read Barron’s chapter 7 and BPJ lesson 40 about recursion. Write down any notes that you think are important. They can be in any form like questions and answers, or simply questions which you don’t understand. Everyone has to submit at least 25 notes or remarks.