EldiraSesto

ContainerElement

May 13th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package container;
  2.  
  3. import container.IContainerElement;
  4.  
  5. public class ContainerElement<E> implements IContainerElement<E> {
  6.  
  7. //an object of type E
  8. E data;
  9. IContainerElement<E> next;
  10.  
  11. //constructors
  12. ContainerElement(E data){
  13. this.data=data;
  14. }
  15.  
  16. ContainerElement(E data, IContainerElement<E> next){
  17. this.data=data;
  18. //nez sta da radim sa ovim sljedecim elementom
  19. this.next=next;
  20.  
  21. }
  22.  
  23. public E getData(){
  24. return data;
  25.  
  26. }
  27.  
  28. public IContainerElement<E> getNextElement(){
  29. return next;
  30. }
  31.  
  32. public boolean hasNextElement() {
  33. if(next==null) return false;
  34. return true;
  35.  
  36. }
  37.  
  38. public void setNextElement (IContainerElement<E> next){
  39. this.next=next;
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment