Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private T[] array =(T[]) new Objects[10];
- @Override
- public void push(T elem) {
- int counter = 0;
- for (int i = 0; i < array.length; i++) {
- if (array[i] == null) {
- break;
- }
- counter++;
- }
- if (counter == 0) {
- array[0] = elem;
- } else {
- for (int i = 0; i < array.length; i++) {
- if (array[i] == null) {
- array[i] = elem;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement