Welcome to CSE 143! Go to pollev.com/cse143.

Slides:



Advertisements
Similar presentations
Building Java Programs
Advertisements

1 CSE 143 Lecture 1: ArrayList reading: Welcome to CSE 143! I'm Allison Obourn
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
CSE373 Optional Section Java Collections 11/12/2013 Luyi Lu.
The Java Collections Framework (JCF) Introduction and review 1.
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.
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.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Thomas Kuehne.
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
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Marcus Frean.
Building Java Programs Chapter 10 ArrayList Copyright (c) Pearson All rights reserved.
Using the Java Collection Libraries COMP 103 # T2
slides created by Marty Stepp
Building Java Programs
Collections.
Wednesday Notecards. Wednesday Notecards Wednesday Notecards.
JAVA COLLECTIONS LIBRARY
JAVA COLLECTIONS LIBRARY
CSE 373: Data Structures and Algorithms
Building Java Programs Chapter 14
Week 2: 10/1-10/5 Monday Tuesday Wednesday Thursday Friday
Road Map CS Concepts Data Structures Java Language Java Collections
Building Java Programs
Road Map CS Concepts Data Structures Java Language Java Collections
Welcome to CSE 143!.
Building Java Programs
Road Map - Quarter CS Concepts Data Structures Java Language
Building Java Programs Chapter 10
Building Java Programs
CS 106A, Lecture 19 ArrayLists
Lecture 2: Implementing ArrayIntList reading:
ArrayLists.
Building Java Programs
Building Java Programs
CSE 143 Lecture 4 ArrayList Reading: 10.1.
CSE 142 vs CSE 143 CSE 142 CSE 143 You learned how to write programs and decompose large problems with: Print statements Methods Control Structures.
ArrayLists.
Building Java Programs Chapter 10
Words exercise Write code to read a file and display its words in reverse order. A solution that uses an array: String[] allWords = new String[1000]; int.
CSE 143 Lecture 1 Arrays (review); ArrayList reading: 10.1
Building Java Programs
CSE 143 Lecture 1 Arrays (review); ArrayList reading: 10.1
Chapter 10 ArrayList reading: 10.1
CSE 143 Lecture 2 Collections and ArrayIntList
Welcome to CSE 143!.
Lecture 1: ArrayList reading: 10.1
Lecture 2: Implementing ArrayIntList reading:
Road Map - Quarter CS Concepts Data Structures Java Language
Building Java Programs
Exercise Write a program that counts the number of unique words in a large text file (say, Moby Dick or the King James Bible). Store the words in a collection.
Building Java Programs
Lecture 13: ArrayLists AP Computer Science Principles
CSE 143 Lecture 4 Implementing ArrayIntList
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.
Road Map - Quarter CS Concepts Data Structures Java Language
Road Map CS Concepts Data Structures Java Language Java Collections
CSE 143 Lecture 3 Implementing ArrayIntList reading:
ArrayLists.
Parsing JSON, Using Libraries, Java Collections, Generics
slides created by Marty Stepp
Building Java Programs
slides created by Marty Stepp
Lecture 7: Linked List Basics reading: 16.2
CSE 373 Java Collection Framework reading: Weiss Ch. 3, 4.8
CS 240 – Advanced Programming Concepts
CSE 143 Lecture 1 Arrays (review); ArrayList reading: 10.1
Presentation transcript:

Welcome to CSE 143! Go to pollev.com/cse143

Context for CSE 143 CSE 142 Control: loops, if/else, methods, parameters, returns I/O: Scanners, user input, files Data: primitive types (int, double, etc.), arrays, classes CSE 143 Control: recursion Data Java collections Classes + Object Oriented Programming Best of CS

Road Map CS Concepts Data Structures Java Language Java Collections Client/Implementer Efficiency Recursion Regular Expressions Grammars Sorting Backtracking Hashing Huffman Compression Data Structures Lists Stacks Queues Sets Maps Priority Queues Java Language Exceptions Interfaces References Generics Comparable Inheritance/Polymorphism Abstract Classes Java Collections Arrays ArrayList LinkedList Stack TreeSet / TreeMap HashSet / HashMap PriorityQueue

Collections collection: an object that stores data; a.k.a. "data structure" the objects stored are called elements some collections maintain an ordering; some allow duplicates typical operations: add, remove, clear, contains (search), size examples found in the Java class libraries: (covered in this course!) ArrayList, LinkedList, HashMap, TreeSet, PriorityQueue all collections are in the java.util package import java.util.*;

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

ArrayList methods (10.1)* add(value) appends value at end of list add(index, value) inserts given value just before the given index, shifting subsequent values to the right clear() removes all elements of the list indexOf(value) returns first index where given value is found in list (-1 if not found) get(index) returns the value at given index remove(index) removes/returns value at given index, shifting subsequent values to the left set(index, value) replaces value at given index with given value size() returns the number of elements in list toString() returns a string representation of the list such as "[3, 42, -7, 15]"

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);