Comment on Tutorial - Stack example in Java - push(), pop(), empty(), search() By Henry
Comment Added by : eissen
Comment Added at : 2014-09-22 13:32:20
Comment on Tutorial : Stack example in Java - push(), pop(), empty(), search() By Henry
public class zcxzcStack
{
//push function/method
// please change the code thank you
static int[] push(int [] stack, int element, int top )
{
stack[++top] = element;
return stack;
}
// please change the code thank you
//pop function/method
static int[] pop(int [] stack, int top)
{
int pop = 0;
stack[top--] = pop;
return stack;
}
// please change the code thank you
//display
public static void main (String[]args)
{
int stack[] = new int[10];
int top = -1;
//push
stack = push(stack,12,top++);
stack = push(stack,13,top++);
stack = push(stack,14,top++);
/*//Pop
stack = pop(stack,top--);
*/
//set elements to -1;
// please change the code thank you
for ( int i = 0; i < stack.length; i++ )
if (stack[i] !=0 )
System.out.print(stack[i] + " ");
System.out.println();
// please change the code thank you
}
}
View Tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Subscribe to Tutorials
Related Tutorials
Program using concept of byte long short and int in java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java
Archived Comments
1. Nice example. Thank you very much.
View Tutorial By: vinod at 2012-06-19 11:19:53
2. Animation code(very Similar to this) is not workin
View Tutorial By: Rakesh Kumar at 2012-04-23 09:42:55
3. sr
thanks 4 information provided
b
View Tutorial By: veer kumar at 2012-07-25 18:30:38
4. Friends i m getting error while intrepreting the e
View Tutorial By: Hanuman at 2014-02-04 14:14:00
5. VERY good info. Providing By YOU Thanx.
View Tutorial By: Ravi singh at 2013-11-14 08:56:34
6. Good start for me. At least I now know what i am s
View Tutorial By: eoaddai at 2011-12-23 20:53:35
7. how to execute all the 5 files plz tell me step by
View Tutorial By: asraf at 2007-11-14 22:29:20
8. i am getting a error when try this sms application
View Tutorial By: Prabhash at 2009-06-03 06:45:26
9. Hi Maybelline, This is the <a href="http:/
View Tutorial By: Daniel Malcolm at 2008-08-21 06:57:31
10. ok this is gud example to build an abstract class.
View Tutorial By: ashish at 2011-12-01 06:22:32