This is my first time to use a List. I have a Class named Foods and I want to make a dynamic list out of it. I wrote the first line that you can see below and then there are a lot of methods that just popped out that I need to override. What should I write in each method? Or is this the right way to make an instance of a list?
public List<Foods> food = new List<Foods>() {
//then these list of methods just popped out//
@Override
public int size() {
return 0;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean contains(Object o) {
return false;
}
@NonNull
@Override
public Iterator<Foods> iterator() {
return null;
}
@NonNull
@Override
public Object[] toArray() {
return new Object[0];
}
@NonNull
@Override
public <T> T[] toArray(@NonNull T[] ts) {
return null;
}
@Override
public boolean add(Foods foods) {
return false;
}
@Override
public boolean remove(Object o) {
return false;
}
@Override
public boolean containsAll(@NonNull Collection<?> collection) {
return false;
}
@Override
public boolean addAll(@NonNull Collection<? extends Foods> collection) {
return false;
}
@Override
public boolean addAll(int i, @NonNull Collection<? extends Foods> collection) {
return false;
}
@Override
public boolean removeAll(@NonNull Collection<?> collection) {
return false;
}
@Override
public boolean retainAll(@NonNull Collection<?> collection) {
return false;
}
@Override
public void clear() {
}
@Override
public Foods get(int i) {
return null;
}
@Override
public Foods set(int i, Foods foods) {
return null;
}
@Override
public void add(int i, Foods foods) {
}
@Override
public Foods remove(int i) {
return null;
}
@Override
public int indexOf(Object o) {
return 0;
}
@Override
public int lastIndexOf(Object o) {
return 0;
}
@NonNull
@Override
public ListIterator<Foods> listIterator() {
return null;
}
@NonNull
@Override
public ListIterator<Foods> listIterator(int i) {
return null;
}
@NonNull
@Override
public List<Foods> subList(int i, int i1) {
return null;
}
};