Skip to content

Instantly share code, notes, and snippets.

@jjlumagbas
Created September 16, 2016 01:33
Show Gist options
  • Save jjlumagbas/d46ddb9fe99a33bf70e4477865245600 to your computer and use it in GitHub Desktop.
Save jjlumagbas/d46ddb9fe99a33bf70e4477865245600 to your computer and use it in GitHub Desktop.
public class AList {
private String[] items;
private int count;
public AList() {
items = new String[10];
count = 0;
}
public void add(String item) {
items[count++] = item;
}
public void add(int i, String item) {
items[i] = item;
count++;
}
public String get(int i) {
if (count == 0 || i >= count) {
throw new IndexOutOfBoundsException();
}
return items[i];
}
public void remove(int i) {
count--;
}
public void set(int i, String item) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment