answersLogoWhite

0


Best Answer

class MyStack implements Stack

{

private String a[]=new String[10];

private int top=0;

public void push(String value)

{

a[top]=value;

top++;

}

public String pop()

{

top--;

return a[top];

}

public int length()

{

return top;

}

public void print()

{

for(int i=0;i<top;i++)

System.out.println(a[i]);

}

}

public class StackOperations

{

public static void main(String args[])

{

MyStack ms = new MyStack();

ms.push("silpa");

ms.push("arti");

ms.print();

System.out.print("popped element is ");

System.out.println(ms.pop());

System.out.print("Now stack is with: ");

ms.print();

}

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Implementing stack operation using array representation with java program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

C program for storage representation of 2-D array?

Wright a 'C' program for storage representation of 2-D array.


Full defecation of array?

Full representation of an array begins from the index 0 and ends at n-1 where n is the number of variables of the array.


How do you use push operation in stack give the exampale of the program?

A stack can be implemented as an array or a list. If an array, simply push the new element onto the end of the array. If a list, point the new node at the head node then make the new node the new head of the list.


What are types of array operation?

Here are some: Create an array Destroy it Access an element of it


True or false a group of hard drives implementing RAID is called an array?

False


What are the design issue for array?

What is its size? How is its size determined and when (compile/run-time). What does the software using the array do when the array is empty? partially full? full? Avoid the software addressing elements of the array which are undefined, or addressing elements outside the bounds of the array When and who is responsible for allocating and freeing memory when the array is no longer needed (program or called procedure start/termination) or some other time determined during program execution. If the array is implementing a data structure such as a stack, queue, dequeue, list, etc. What is its implementation of the usual data structure operations, Create, Empty, List Items, Top, First, Last, Next, etc.


Can linked list represent in array if yes show how insertion and deletions can perform in array representation of inked list?

yes


How do you use in array?

cod a program student degree array in c language


How can arrays within decisions improve program efficiency?

When a significant number of values must be tested to perform an operation, an array is more efficient then "if else" or "switch case" statements. Juge by the following example in C: const char* ConverteIntegerToCStr( unsigned int number, char cstr[] ) { // predefined array with the first 10000 number string representation // Note: the ellipsis is not part of the code static const Array[10000] = { "0", "1", "2", ..., "9998", "9999" }; if (number &lt; 10000) memcpy( cstr, Array[number], strlen( Array[number] ) ); // very fast else itoa( number, cstr ); // standard C function that is much slower return cstr; }


Is A group of hard drives implementing RAID called an array?

RAID stands for a redundant array of independent disks. Thus, a group of two or more hard disks comprise a RAID, or array of physically separate drives.


Program to count the number of numbers in an array using 8085 microprocessor?

A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.


What is a group of hard drive implementing RAID called?

A group of hard drives assembled into a RAID array is often referred to as, well, a "RAID array" a "RAID stack" or a "RAID cluster."