- packagecom.eshore.sweetop.dataframe;
- publicclassStack{
- privateinttop=-1;
- privateint[]s;
- publicStack(){
- s=newint[100];
- }
- publicStack(intn){
- s=newint[n];
- }
- publicbooleanisEmpty(){
- returntop==-1;
- }
- publicvoidpush(intx){
- top++;
- s[top]=x;
- }
- publicintpop(){
- if(isEmpty()){
- thrownewRuntimeException("Thisstackisempty");
- }
- top--;
- returns[top+1];
- }
- publicstaticvoidmain(String[]args){
- Stacks=newStack();
- s.push(1);
- s.push(4);
- System.out.println(s.pop());
- }
- }