COMPSCI 61B Study Guide - Midterm Guide: Preorder, Comparator, Data Type
For
Midlrm
2
Notes
2/9 4.4 11
.libraries ,Abstract Classes ,Packages Lee 1
Review : Interface Inheritance for Comparison
•Our comparable
.com Pareto (object )
.in java :cant pass functions inside parameters
comparator at >
°compare KT >
,<t>)
Abstract Data type :defined by its Operations ,not by its implementation
°ex :Stack
°push (int a) :puts x on top of stack
.int pop C) :removes ¢returns top item
→for linked list keep atop pointer &then Linked list &
Andy are both efficient AL >Array list )
Yresizeing .a)
.ex :Grab Bag
.insert Cintas
removed
.sampled
.
size ()
→Array is more evident
Collections
ojavavtil library :important interfaces :those that extend the collection
interlace
°Lists of things
•sets of things
•Mapping between items
→associative arrays ,
associative lists (Lisp ,symbol tables ,dktcpyty
→
keys
collection
list set Map
Linked Away Hash Tree Hashmaptreemqp
List List set Set ←
no order giveinalpheb
but efficient
order
sets :onyadsunigvevawes
Interfaces
everymethodnastobe public (so public is redundant
.unless keyword default →method is abstract
.have Manopvblicstaticfinal constants
can't be instantiated
Abstract Class
cant be instantiated public abstract class
.canhaveeitherabstractkoncrde
.Use abstract keyword for abstract methods
default ⇒concrete
ianyvanableslany
methods
pnvatelpvblicisfinl
Packages
.
namespace that organizes classes Elinterfaoes
.addresses the fact that classes might share hames
package Ugjoshh .animal ;
public class Dog {.
.
.
ofromovtsideuseentirecanonicalnamo
ugjoshh .animal .Dogd-- new ....
icahshotenwithiimpovtugijushh .animal -1709 ;
Dogokheu Dog
Document Summary
Pareto ( object ) in java : cant comparator pass at functions inside parameters compare. Data type defined by its operations , not by its implementation. : puts x removes on top of stack returns top item list both keep a top efficient pointer then. Push ( int a) int for pop c) : linked are. Lists sets of of things things: mapping between associative keys items arrays , interfaces those that extend the collection associative lists ( lisp , symbol tables. Hashmaptreemqp no but order efficient giveinalpheb order sets onyadsunigvevawes. Interfaces everymethodnastobe default unless keyword public ( so. Method is public is abstract redundant have can"t. Use be instantiated public abstract class canhaveeitherabstractkoncrde abstract for keyword abstract methods default concrete ianyvanableslanymethods pnvatelpvblicisfinl. Packages namespace that organizes that classes classes might. Elinterfaoes share hames addresses package public fact the. Ugjoshh . class dog { animal ofromovtsideuseentirecanonicalnamo ugjoshh . animal. Generics a specifying type arg primitive can"t use.