Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Zbior<T>
- {
- public int liczba;
- private T element;
- private ArrayList<T> tab;
- public Zbior(T element)
- {
- this.element = element;
- }
- public Zbior (int liczba)
- {
- this.liczba = liczba;
- tab = new ArrayList<T>();
- }
- public T pobierzElement()
- {
- return element;
- }
- public void dodaj (int a)
- {
- tab.add(a);
- }
- public boolean pusty()
- {
- if (tab.size()==0) return true;
- else return false;
- }
- public int pierwszy()
- {
- int a = tab.get(0);
- return a;
- }
- public void usun_pierwszy()
- {
- tab.remove(0);
- }
- public static void main(String[] args)
- {
- Zbior<Integer> zb = new Zbior<Integer>(10);
- int j=0;
- for ( int i=0 ; i<5 ; ++i ) {
- j++;
- zb.dodaj(j);
- }
- while (!zb.pusty()) {
- System.out.println(zb.pierwszy());
- zb.usun_pierwszy();
- }
- }
- }
Add Comment
Please, Sign In to add comment