public class Test_21_1<E> { private int pos = 0; E array1[] , array2[]; public int getSize(){ if(array1.length < array2.length) return array2.length; else return array1.length; } public E peek(){ // return the top value if(array1.length < array2.length) return array2[pos]; else return array1[pos]; } public void push(E o){ //add element if(pos < getSize() - 1) array[pos] = o; else { System.arraycopy(array,0,array1,0,getSize()); array1[pos] = o; } pos++; } public E pop(){ //return and remove the top element return } public E isEmpty(){ } public static void main(String[] args) { // TODO Auto-generated method stub } }
时间: 2024-10-17 06:22:17