Unformatted text preview:

Lecture 2 April 2nd 2014 public class Lecture2 Client you will actually run public class ArrayIntListClient public static void main String args ArrayIntLIst list1 new ArrayIntList list1 elementData 0 23 list1 size list1 add 23 System out println list1 Class Null pointer exception hasn t been properly initalized in this case no constructor public class ArrayIntList private int size encapsulating fields Hiding data away from client private int elementData public ArrayIntList elementData new int 10 0 add 23 23 1 1 add 56 23 56 2 2 add 45 23 56 45 3 Warning size might become greater than 10 public void add int value elementData size value size public void add int index int value for int i size i index i elementData i elementData i 1 elementData index value size public String toString String result Only return this String if there is an array Thus if statement if size 0 result elementData 0 for int i 1 i size i result elementData i result return result


View Full Document

UW CSE 143 - Lecture 2

Documents in this Course
Load more
Download Lecture 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?