Class Notes (1,100,000)
US (480,000)
Rutgers (10,000)
4:18 (400)
Lecture 19

01:198:111 Lecture 19: 11/7 - Partial Midterm 2 Review + More 2D Arrays + Array listsPremium

Computer Science
Course Code

This preview shows half of the first page. to view the full 2 pages of the document.
Midterm 2 Review - This is only a partial review of topics you need to cover, not a full
Need to know:
Arrays and their properties
Strings and their properties
Know the methods as well, you will be given a sheet that displays
you the syntax of the methods, but make sure you know how to
use them
Potential problems:
Reverse a number
How to find a bugs in code and what can be done to fix it
Can involve strings as well
Tracing functions and their outputs
Object Oriented Programming
Define instance variables, methods, constructors, classes, etc…
How to write them
How to test them
When looking at a function or trying to create one, break it down
What is the function taking in?
Do I have to return anything?
What do I need to return if I have to return something?
Review sheet with problems can be found online at Sakai Resources
2D Arrays
Basically 2D arrays are very similar to regular arrays, the only difference is you
have to deal with two indexes instead of one
Arrays are references and as such editing arrays using functions do not require
anything to be returned
You can return the array back if you wish
Example problem: Write a function that allows you to edit an array at
positions int [ i ][ j ]
public static array int [ ][ ] setEntry(int [ ][ ] a, int i, int j, int n){
if (i<0 || i > a.length-1) return null; //null means you are
returning basically nothing
if (j<0 || i > a[ 0 ].length-1) return null;
a[ i ][ j ] = n; //This is the only part of the code that actually
changes anything
return a; //This returns the array back into the main
The only way you can create an array is by either saying new or giving it
values, e.g.
New method:
You're Reading a Preview

Unlock to view full version

Subscribers Only