1 / 28

Lecture 27

COP3502: Introduction to CIS I. Lecture 27. Pset 0 3% Pset 1 5% Pset 2 7% Pset 3 15% Pset 4 20% Pset 5 20 % Exam 1 10% Exam 2 10% Labs 10%. l ab 5. c ipher decoder. p roblem set 4. “interactive text adventure”. r eading a file.

kathy
Download Presentation

Lecture 27

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COP3502: Introduction to CIS I Lecture 27

  2. Pset 0 3% • Pset 1 5% • Pset2 7% • Pset 3 15% • Pset 4 20% • Pset 5 20 % • Exam 1 10% • Exam 2 10% • Labs 10%

  3. lab 5 cipher decoder

  4. problem set 4 “interactive text adventure”

  5. reading a file • Open the file • BufferedReaderbr = new BufferedReader(new FileReader(filename)); • Read the file line by line • String line = br.readLine(); • Close the file • br.close();

  6. writing a file • Open the file • PrintWriter pw = new PrintWriter(new FileWriter(filename)); • Print the file line by line • pw.println(text); • Close the file • pw.close();

  7. catching exceptions try { //some code } catch (Exception ex) { //hande the exception in some way }

  8. java collections containers used to store, retrieve, andmanipulate aggregate data generic

  9. java collections containers used to store, retrieve, andmanipulate aggregate data generic ex: arrays

  10. java collections containers used to store, retrieve, andmanipulate aggregate data generic ex: arrays, ArrayList

  11. Collection

  12. List interface add() get() remove() size() contains()

  13. Collection List

  14. Collection List ArrayList

  15. Collection List LinkedList ArrayList

  16. Collection Set List Queue HashSet SortedSet LinkedList PriorityQueue NavigableSet ArrayList LinkedHashSet TreeSet

  17. Map

  18. maps set of key/value pairs

  19. examples of maps dictionary phone book

  20. dictionary key: word to look up value: definition access values in a map by looking up the key

  21. dictionary key: word to look up value: definition access values in a map by looking up the key maps Strings to Strings

  22. Map HashMap

  23. Map HashMap SortedMap TreeMap

  24. HashMap new HashMap<K, V>() K – type of key V – type of value

  25. HashMap methods put(key, value)

  26. HashMap methods value = get(key)

  27. HashMap methods remove(key)

  28. HashMap methods contains(key)

More Related