JAVA WEEK5(A)
/* Week 5 : a) Write a Java program that: i) Implements stack ADT. */



import javax.swing.*;
class stack
{...
Upcoming SlideShare
Loading in …5
×

Java Week5(A) Notepad

419 views
365 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
419
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Java Week5(A) Notepad

  1. 1. JAVA WEEK5(A) /* Week 5 : a) Write a Java program that: i) Implements stack ADT. */ import javax.swing.*; class stack { int stck[]=new int[10]; int top; String res; stack() { top=-1; } void push(int item) { if(top==9) System.out.println("stack is full"); else stck[++top]=item; } int pop() { if(top<0) { System.out.println("stack is underflow"); return 0; } else return stck[top--]; } void display(int n) { res=" "; for(int i=0;i<4); } } Page 1

×