© A+ Computer Science - www.apluscompsci.com Which of the following statements assigns the letter S to the third row and first column of a two-dimensional.

Slides:



Advertisements
Similar presentations
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
Advertisements

Chapter 8. 2 Objectives You should be able to describe: One-Dimensional Arrays Array Initialization Arrays as Arguments Two-Dimensional Arrays Common.
JAVA 1.5 New Features Dr V. The syntax of the enhanced for loop (for each) for (type variableName : arrayName) { statements } arrayName could be any.
© A+ Computer Science - ArrayList © A+ Computer Science - Lab 16.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
1 CSCE 1030 Computer Science 1 Arrays Chapter 7 in Small Java.
03/16/ What is an Array?... An array is an object that stores list of items. Each slot of an array holds an individual element. Characteristics.
Programming With Java ICS201 University Of Ha’il1 Chapter 14 Generics and The ArrayList Class.
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Two dimensional arrays in Java Computer Science 3 Gerb Objective: Use matrices in Java.
Arrays and Array Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
How to do well on the AP CS Free Response Questions
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
© A+ Computer Science - A queue is a group of same-type values. Values are added to the back of a queue and removed from the front.
CHAPTER 7 arrays I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Enhanced For Loops (For Each Loops) Less Code and Less Overhead for Writing For Loops.
Wrapper Classes and ArrayList Mrs. C. Furman 9/15/2008.
© A+ Computer Science - Grid is an interface that details the behaviors expected of a grid. All its methods are abstract methods.
Week # 2: Arrays.  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently  Types of data.
AP Computer Science edition Review 1 ArrayListsWhile loopsString MethodsMethodsErrors
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: One-Dimensional Arrays Array Initialization Arrays.
© A+ Computer Science - A reference variable stores the memory address of an object. Monster fred = new Monster(); Monster sally.
© A+ Computer Science - In Java, any variable that refers to an Object is a reference variable. The variable stores the memory.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 11P. 1Winter Quarter Arrays Lecture 11.
1. Define an array 1 Create reference arrays of objects in Java program 2 Initialize elements of arrays 3 Pass array to methods 4 Return array to methods.
Arrays.
How to do well on the AP CS Free Response Questions
Multidimensional Arrays tMyn1 Multidimensional Arrays It is possible to declare arrays that require two or more separate index values to access an element.
© A+ Computer Science - import java.util.Scanner; Try to be as specific as possible when using an import.
13/10/2016CS150 Introduction to Computer Science 1 Multidimensional Arrays  Arrays can have more than one column  Two dimensional arrays have two columns.
Arrays and Array Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
© A+ Computer Science - In Java, any variable that refers to an Object is a reference variable. The variable stores the memory.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
Arrays. What is an array? An array is a collection of data types. For example, what if I wanted to 10 different integers? int num1; int num2; int num3;
Arrays and Array Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos and Alexandra Stefan University of Texas at Arlington 1.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
Introduction to programming in java Lecture 21 Arrays – Part 1.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Scanner frequently used methods NameUse nextInt()returns the next int value nextDouble()returns the next.
 2003 Prentice Hall, Inc. All rights reserved. 1 Arrays Outline 1 Introduction 2 Arrays 3Declaring Arrays 4Processing Array Contents 5 Multiple-Subscripted.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Elevens is a lab about classes and Lists. List is a major concept being tested by the Elevens lab. Elevens.
Two-Dimensional Arrays
(like an array on steroids)
Two Dimensional Array Mr. Jacobs.
A+ Computer Science AP Review 2018 AP CS A EXAM
Java Array Lists 2/2/2016.
Java Array Lists 2/13/2017.
Multiple Choice -answer the easiest question 1st
A+ Computer Science INPUT.
© A+ Computer Science - Arrays and Lists © A+ Computer Science -
ArrayLists.
The Matrix A b a d e a a a a a a a A b a d e a a a a a a a
Methods Copying Autoboxing
Arrays.
Java Array Lists 2/13/2017.
© A+ Computer Science - Classes And Objects © A+ Computer Science -
© A+ Computer Science - OOP Pieces © A+ Computer Science -
A+ Computer Science INPUT.
See requirements for practice program on next slide.
Java Array Lists Day 2.
ArrayList Day 3 Be able to read AP Mult Choice questions tied to ArrayLists Be able to write a program that uses ArrayLists that analyzes numbers.
Java: Variables, Input and Arrays
A+ Computer Science AP Review 2019 AP CS A EXAM
Presentation transcript:

© A+ Computer Science - Which of the following statements assigns the letter S to the third row and first column of a two-dimensional array named letterGrid (assuming row-major order). Answer a: letterGrid[3][1] = "S"; Answer b: letterGrid[1][3] = "S"; Answer c: letterGrid[0][2] = "S"; Answer d: letterGrid[2][0] = "S"; Answer e: letterGrid.setValue(2,0,"S");

© A+ Computer Science -

Consider the following code segment: ArrayList list; list = new ArrayList (); list.add(new Integer(1)); list.add(new Integer(2)); list.add(new Integer(3)); list.set(2, new Integer(4)); list.add(2, new Integer(5)); l ist.add(new Integer(6)); System.out.println(list); What is printed as a result of executing the code segment?

© A+ Computer Science - Arraylist is a class that houses an array. An ArrayList can store any type. All ArrayLists store the first reference at spot / index position 0.

© A+ Computer Science nums int[] nums = new int[10]; //Java int array An array is a group of items all of the same type which are accessed through a single identifier.

© A+ Computer Science - list nothing null ArrayList list; list is a reference to an ArrayList.

© A+ Computer Science - 0x213 new ArrayList(); ArrayLists are Objects. []

© A+ Computer Science - list 0x213 ArrayList list = new ArrayList(); list is a reference to an ArrayList. []

© A+ Computer Science - List ray = new ArrayList(); ray.add("hello"); ray.add("whoot"); ray.add("contests"); out.println(((String)ray.get(0)).charAt(0)); out.println(((String)ray.get(2)).charAt(0)); ray stores Object references. OUTPUT h c

© A+ Computer Science -

With Java 5, you can now specify which type of reference you want to store in the ArrayList. ArrayList words; words = new ArrayList (); List decNums; decnums = new ArrayList ();

© A+ Computer Science - With Java 5, you can now specify which type of reference you want to store in the ArrayList. ArrayList bigStuff; bigStuff = new ArrayList (); List itList; itList = new ArrayList ();

© A+ Computer Science - List ray; ray = new ArrayList (); ray.add("hello"); ray.add("whoot"); ray.add("contests"); out.println(ray.get(0).charAt(0)); out.println(ray.get(2).charAt(0)); ray stores String references. OUTPUT h c

© A+ Computer Science -

ArrayList frequently used methods NameUse add(item)adds item to the end of the list add(spot,item)adds item at spot – shifts items up-> set(spot,item)put item at spot z[spot]=item get(spot)returns the item at spot return z[spot] size()returns the # of items in the list remove()removes an item from the list clear()removes all items from the list import java.util.ArrayList;

© A+ Computer Science - ArrayList words; words = new ArrayList (); words.add(0,"it"); words.add("is"); words.add("a"); words.add("lie"); out.println(words); OUTPUT [it, is, a, lie]

© A+ Computer Science - ArrayList nums; nums = new ArrayList (); nums.add(34); nums.add(0,99); nums.add(21); nums.add(11); out.println(nums); OUTPUT [99, 34, 21, 11]

© A+ Computer Science - ArrayList ray; ray = new ArrayList (); ray.add(23); ray.add(11); ray.set(0,66); ray.add(53); ray.set(1,93); ray.add(22); out.println(ray); OUTPUT [66, 93, 53, 22]

© A+ Computer Science - for (int i=0; i<ray.size(); i++) { out.println(ray.get(i)); }.size( ) returns the number of elements/items/spots/boxes or whatever you want to call them.

© A+ Computer Science - ArrayList ray; ray = new ArrayList (); ray.add(23); ray.add(11); ray.add(12); ray.add(65); out.println(ray.get(0)); out.println(ray.get(3)); OUTPUT get(spot) returns the reference stored at spot !

© A+ Computer Science - ArrayList ray; ray = new ArrayList (); ray.add(23); ray.add(11); ray.add(12); ray.add(65); for(int i=0; i<ray.size(); i++) out.println(ray.get(i)); OUTPUT get(spot) returns the reference stored at spot !

© A+ Computer Science -

ArrayList ray; ray = new ArrayList (); ray.add("a"); ray.add("b"); ray.remove(0); ray.add("c"); ray.add("d"); ray.remove(0); out.println(ray); OUTPUT [c, d]

© A+ Computer Science - ArrayList ray; ray = new ArrayList (); ray.add("a"); ray.add("b"); ray.remove("a"); ray.add("c"); ray.add("d"); ray.remove("d"); out.println(ray); OUTPUT [b, c]

© A+ Computer Science - ArrayList ray; ray = new ArrayList (); ray.add(23); ray.add(11); ray.add(53); for(int num : ray){ out.println(num); } OUTPUT