Go to pollev.com/cse143.

Slides:



Advertisements
Similar presentations
CSE 143 Lecture 22: Advanced List Implementation (ADTs; interfaces; abstract classes; inner classes; generics; iterators)
Advertisements

CSE 143 Lecture 3 Inheritance slides created by Marty Stepp
Building Java Programs
1 CSE 143 Lecture 1: ArrayList reading: Welcome to CSE 143! I'm Allison Obourn
CSE 143 Lecture 14 Interfaces; Abstract Data Types (ADTs) reading: 9.5, 11.1; 16.4 slides created by Marty Stepp
CSE 143 Lecture 2 More ArrayList ; classes and objects reading: 10.1; slides created by Marty Stepp and Hélène Martin
Copyright 2008 by Pearson Education Building Java Programs Chapter 10 Lecture 10-1: ArrayList reading: 10.1.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
CSE 143 Lecture 24 Advanced collection classes (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, , slides.
CSE 143 Lecture 2 ArrayList reading: 10.1 slides created by Marty Stepp
Copyright 2010 by Pearson Education Building Java Programs Chapter 10 Lecture 21: ArrayList reading: 10.1.
Generics in C# 1. Generics List vs. non-generic ArrayList Generic List Namespace System.Collections.Generic List list = new List (); List.add(”Anders”);
CSE 143 Lecture 2 More ArrayList ; classes and objects reading: 10.1; slides created by Marty Stepp and Hélène Martin
CSE 143 Lecture 4 Exceptions and ArrayList slides created by Marty Stepp
CSE 143 Lecture 3 Implementing ArrayIntList reading: slides created by Marty Stepp and Hélène Martin
Building Java Programs Chapter 10 ArrayList Copyright (c) Pearson All rights reserved.
Building Java Programs Interfaces reading: , 16.4.
slides created by Marty Stepp
Lecture 13: Interfaces, Comparable reading: , 16.4, 10.2
Collections.
Collections.
CSE 143 Lecture 3 More ArrayList; object-oriented programming
Building Java Programs
Collections.
Welcome to CSE 143!.
Building Java Programs
Building Java Programs Chapter 10
Lecture 2: Implementing ArrayIntList reading:
Building Java Programs
Building Java Programs
ArrayLists.
Building Java Programs Chapter 10
Building Java Programs
CSE 143 Lecture 27: Advanced List Implementation
Lecture 26: Advanced List Implementation
CSE 143 Lecture 1 Arrays (review); ArrayList reading: 10.1
Building Java Programs
Building Java Programs
CSE 143 Lecture 1 Arrays (review); ArrayList reading: 10.1
Chapter 10 ArrayList reading: 10.1
ArrayLists.
CSE 143 Lecture 2 Collections and ArrayIntList
Lecture 1: ArrayList reading: 10.1
Lecture 2: Implementing ArrayIntList reading:
Welcome to CSE 143! Go to pollev.com/cse143.
Building Java Programs
slides created by Ethan Apter
Lecture 13: ArrayLists AP Computer Science Principles
CSE 143 Lecture 4 Implementing ArrayIntList
CSE 143 Lecture 2 More ArrayList; classes and objects
slides created by Marty Stepp
Lecture 16: Arraylist Building Java Programs: A Back to Basics Approach by Stuart Reges and Marty Stepp Copyright (c) Pearson All rights reserved.
Go to pollev.com/cse143.
CSE 143 Lecture 3 Implementing ArrayIntList reading:
CSE 143 Lecture 4 Implementing ArrayIntList; Binary Search
Building Java Programs
slides created by Alyssa Harding
CSE 143 Lecture 2 ArrayIntList, binary search
slides created by Ethan Apter
Building Java Programs
slides created by Marty Stepp
CSE 143 Lecture 3 More ArrayList; object-oriented programming
slides created by Marty Stepp
Lecture 7: Linked List Basics reading: 16.2
CSE 143 Lecture 6 interfaces; eclipse; testing
CSE 143 Lecture 4 Implementing ArrayIntList reading:
CSE 143 Lecture 21 Advanced List Implementation
ArrayLists Readings: 10.1 (pg. 559 – 571).
CSE 143 Lecture 1 Arrays (review); ArrayList reading: 10.1
Implementing ArrayIntList
Presentation transcript:

Go to pollev.com/cse143

Lists list: a collection of elements with 0-based indexes elements can be added to the front, back, or elsewhere a list has a size (number of elements that have been added) This is just a high level idea, haven’t said how to do it in Java

pollev.com/cse143 Suppose we had the following method: // Returns count of plural words in the given list. public static int removePlural(ArrayList<String> list) { for (int i = 0; i < list.size(); i++) { String str = list.get(i); if (str.endsWith("s")) { list.remove(i); } What would the output be after the method call? ArrayList<String> list = …; // [a, bs, c, ds, es, f] removePlural(list); System.out.println(list);

Recall: classes and objects class: A program entity that represents: A complete program or module, or A template for a type of objects. (ArrayList is a class that defines a type.) object: An entity that combines state and behavior. object-oriented programming (OOP): Programs that perform their behavior as interactions between objects. abstraction: Separation between concepts and details. Objects provide abstraction in programming.

Client - Radio

Implementer - Radio

Client – ArrayList ArrayList<String> list: [“a”, “b”, “c”]

Implementer - ArrayList String[] elementData: [“a”, “b”, “c”, null, null, null, null, null, null] int size: 3

pollev.com/cse143 Suppose we had the following method: ArrayIntList list1 = new ArrayIntList(); ArrayIntList list2 = new ArrayIntList(); list1.add(1); list2.add(2); list1 = list2; list1.add(3); list2.add(4); What is the state of the lists after these calls? list1: [1, 3] list2: [2, 4] list1: [2, 3] list2: [2, 4] list1: [2, 3, 4] list2: [2, 3, 4] list1: [1, 2, 3] list2: [4] list1: [1, 2, 3, 4] list2: [] Other