Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package StackTask;
- public class Stackimplementation {
- public static void main(String[] args) {
- }
- }
- class Stack{
- private int[] Stack_E;
- private int top = 0;
- private int maxsize = 10;
- public boolean isEmpty(){
- if(top == -1){
- return true;
- }
- else{
- return false;
- }
- }
- public boolean isFull(){
- if(top == maxsize){
- return true;
- }
- else{
- return false;
- }
- }
- public void push(int item){
- if( isFull() ){
- System.out.println("Stack is full");
- }
- else{
- top = top + 1;
- Stack_E[top] = item;
- }
- }
- public int pop(int item){
- if(isEmpty()){
- System.out.println("Stack is empty");
- return 0;
- }
- else{
- item = Stack_E[top];
- top = top - 1;
- return item;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement