1 / 11

Visualizing and Using Arrays: Exam Review & Study Guide

Join us on 2/28 from 5:30-7:30pm at GEO.2.216 for an in-depth exam review session. Brush up on arrays of objects, initializing arrays, swapping elements, and more. Check the detailed schedule for a brief study guide. Don't miss the last chance to review before the exam!

hamish
Télécharger la présentation

Visualizing and Using Arrays: Exam Review & Study Guide

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. Announcements Exam: 2/28 5:30-7:30pm GEO 2.216 Brief study guide on web (see detailed schedule) Last Time: arrays of objects Items[] apples; appleTypes = 8; apples = new Items[appleTypes]; apples[0] = new Items(”Granny Smith", 22); Announcements & Review Lecture 16: Visualizing and Using Arrays

  2. Initializing Array of Objects Items[] apples = new Items[3]; apples -> null null null Lecture 16: Visualizing and Using Arrays

  3. Initializing Array of Objects Items[] apples = new Items[3]; apples[2] = new Items(“Granny Smith”, 22); apples -> null null Lecture 16: Visualizing and Using Arrays

  4. Initializing Array of Objects Items[] apples = new Items[3]; apples[2] = new Items(“Granny Smith”, 22); apples[0] = apples[2]; apples -> null Lecture 16: Visualizing and Using Arrays

  5. Visualizing an Array of Objects ... apple[0].setName("McIntosh”); apple[1].setAmount(10); apples -> Lecture 16: Visualizing and Using Arrays

  6. Swapping Elements // let’s swap apple[0] and apple[2] Items tmp = apple[0]; // Make a temporary copy. Why? apples -> tmp Lecture 16: Visualizing and Using Arrays

  7. Swapping Elements // let’s swap apple[0] and apple[2] Items tmp = apple[0]; // Make a temporary copy. Why? apple[0] = apple[2]; apples -> tmp Lecture 16: Visualizing and Using Arrays

  8. Swapping Elements // let’s swap apple[0] and apple[2] Items tmp = apple[0]; // Make a temporary copy. Why? apple[0] = apple[2]; apple[2] = tmp apples -> tmp Lecture 16: Visualizing and Using Arrays

  9. Swapping Integers // swap a & b public void swap(int a, int b) { int t = a; a = b; b = t; } int a = 10; int b = 20; swap (a, b); // a = 20; b = 10; Lecture 16: Visualizing and Using Arrays

  10. BlueJ Examples Problems • Extend Inventory class for tracking Items Lecture 16: Visualizing and Using Arrays

  11. More Questions? Lecture 16: Visualizing and Using Arrays

More Related