Arrays in Java: Spring 2024 Lesson Overview
Explore the fundamentals of arrays in Java from the Spring 2024 lesson. Understand array creation, traversal patterns, and more. Stay updated on creative projects, quizzes, and reminders for an enriching learning experience in CSE 121. Get ready for practice quizzes and engaging activities to enhance your understanding!
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
CSE 121 Lesson 14: Arrays Matt Wang Spring 2024 Andy Anju Archit Arkita Autumn Christian TAs: Hannah H Hannah S Heather Hibbah Janvi Jessie Jonus Julia Luke Maria Mia Ritesh Shayna Simon Trey Vidhi Vivian Gumball? sli.do #cse121-14 Today s playlist: CSE 121 lecture beats 24sp Lesson 14 - Spring 2024
Announcements, Reminders Creative Project 3 (C3) releasing later tonight; due May 21st Resubmission Cycle 4 (R4) due tomorrow Eligible: C1 (last chance), P1, C2 Quiz 2 on Thursday, May 23rd Covers everything up to (and including) today s material! Stay tuned for extra practice materials (e.g. practice quizzes) Quiz 1 grades should be out by the weekend! Will send an update tonight re: megasection Lesson 14 - Spring 2024
(PCM) Arrays Elements (must all be the same type) Indices (starting at 0) Must decide size when created! arr.length to get arr's length Arrays.toString(arr) to get a nice String version Lesson 14 - Spring 2024
(PCM) Array Traversal Pattern for (int i = 0; i < arr.length; i++) { // do something with arr[i] } Lesson 14 - Spring 2024
Poll in with your answer! How can we get the last element of an array arr? sli.do #cse121-14 A.arr[arr.length()] B.arr[length()] C.arr[arr.length] D.arr[arr.length() - 1] E.arr[arr.length - 1] Lesson 14 - Spring 2024
Poll in with your answer! What would the array a store at the end of this arrayMystery method if {-20, 20, 26, 32, 50, 3} was passed in? sli.do #cse121-14 public static void arrayMystery(int[] a) { for (int i = a.length - 1; i >= 1; i--) { if (a[i] > a[i - 1] + 10) { a[i - 1] = a[i - 1] + 5; } } } A.{-20, 20, 26, 32, 50, 3} B.{-15, 25, 31, 37, 55, 8} C.{-15, 25, 31, 37, 50, 3} D.{-15, 20, 26, 37, 50, 3} Lesson 14 - Spring 2024