-
-
Save deda9/6adefd06c4656d39e45ca334093f3a71 to your computer and use it in GitHub Desktop.
generics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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