SHARE
TWEET

Untitled

a guest Jan 28th, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private T[] array =(T[]) new Objects[10];
  2.  
  3.     @Override
  4.     public void push(T elem) {
  5.         int counter = 0;
  6.         for (int i = 0; i < array.length; i++) {
  7.             if (array[i] == null) {
  8.                 break;
  9.             }
  10.             counter++;
  11.         }
  12.         if (counter == 0) {
  13.             array[0] = elem;
  14.         } else {
  15.             for (int i = 0; i < array.length; i++) {
  16.                 if (array[i] == null) {
  17.                     array[i] = elem;
  18.                 }
  19.             }
  20.         }
  21.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top