Skip to content

Instantly share code, notes, and snippets.

@deda9
Forked from AnnaBoro/Box.java
Created July 11, 2016 15:36
Show Gist options
  • Save deda9/6adefd06c4656d39e45ca334093f3a71 to your computer and use it in GitHub Desktop.
Save deda9/6adefd06c4656d39e45ca334093f3a71 to your computer and use it in GitHub Desktop.
generics
package lesson7_10.generics;
import java.util.ArrayList;
import java.util.List;
public class Box<T>{
private List<T> birdsList;
public Box() {
birdsList = new ArrayList<T>();
}
public T getBird(int birdIndex) {
return birdsList.get(birdIndex);
}
public List<T> getBirdsList() {
return birdsList;
}
public void addBird(T bird) {
birdsList.add(bird);
}
public void removeBird(T bird) {
birdsList.remove(bird);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment