Skip to content

Commit 5990be8

Browse files
committedMar 11, 2016
first person to second person plural
1 parent d8a258f commit 5990be8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
1. Write an implementation of an ArrayList.
77

88

9-
## Implementing an array-backed list
9+
## Implementing an Array-backed List
1010

1111
For this lesson we provide a partial implementation of an ArrayList that uses a Java array to store the elements. We left four of the methods incomplete; your job is to fill them in. We provide JUnit tests you can use to check your work.
1212

@@ -47,7 +47,7 @@ The constructor creates an array of 10 elements, which are initially `null`, and
4747

4848
One detail about Java: You can't instantiate an array of T[], so you have to instantiate an array of Object and then typecast it. You can [read more about this issue here](http://www.ibm.com/developerworks/java/library/j-jtp01255/index.html).
4949

50-
Next we'll look at the method that adds elements to the list. Here's my implementation of `add`:
50+
Next we'll look at the method that adds elements to the list. Here's our implementation of `add`:
5151

5252
```java
5353
public boolean add(E element) {
@@ -67,7 +67,7 @@ If there are no unused spaces in the array, we have to create a bigger array and
6767

6868
It might not be obvious why this method returns a boolean, since it seems like it always returns `true`. As always, [you can find the answer in the documentation](https://docs.oracle.com/javase/7/docs/api/java/util/Collection.html#add(E)).
6969

70-
It's also not obvious how to analyze the performance of this method. In the normal case, it's constant time, but if we have to resize the array, it's linear. In the next README I'll explain how we can handle this.
70+
It's also not obvious how to analyze the performance of this method. In the normal case, it's constant time, but if we have to resize the array, it's linear. In the next README we'll explain how we can handle this.
7171

7272
We'll look at `get` next, and then you can fill in `set`. Actually, `get` is pretty simple:
7373

@@ -100,7 +100,7 @@ HINT: Try to avoid repeating the index-checking code.
100100

101101
* Your next mission is to fill in `indexOf`. As usual, you should [read the documentation](https://docs.oracle.com/javase/7/docs/api/java/util/List.html#indexOf(java.lang.Object)) so you know what it's supposed to do. In particular, notice how it is supposed to handle `null`.
102102

103-
To make things a little easier, I've provided a helper method called `equals` that compares an element from the array to a target value and returns `true` if they are equal (and it handles `null` correctly).
103+
To make things a little easier, we've provided a helper method called `equals` that compares an element from the array to a target value and returns `true` if they are equal (and it handles `null` correctly).
104104
Notice that this method is private because it is used inside this class but it is not part of the `List` interface.
105105

106106
When you are done, run `MyArrayListTest` again; `testIndexOf` should pass now, as well as the other tests that depend on it.

0 commit comments

Comments
 (0)
Please sign in to comment.