Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. package day7.conteiner;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. /**
  6. * Created by admin on 7/27/2016.
  7. */
  8. public class Box<T> {
  9. private ArrayList<T> obj;
  10.  
  11. public Box(){
  12. obj = new ArrayList<>();
  13. }
  14.  
  15. public void addObj(T t){
  16. obj.add(t);
  17. }
  18.  
  19. public T getObj(int index){
  20. return obj.get(index);
  21. }
  22.  
  23. public void removeObj(int index){
  24. obj.remove(index);
  25. }
  26.  
  27. public void removeObject(T t){
  28. obj.remove(t);
  29. }
  30.  
  31. public void printBox(){
  32. for (Object o:obj){
  33. System.out.println(o.toString());
  34. }
  35. }
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement