Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Implementation Stack Using Array

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Implementation Stack Using Array

    Stack is a Linear Data Structure.Stack can be Implemented easily by using an array in Java .Every Stack has two Main Operations/Methods

    a)Push-Used to Insert an Element to the Stack

    b)Pop- Used to Remove an Element from the Stack


     void push(int item)  
      {  
        if(top==n)  
        {  
          System.out.println("STACK IS FULL");  
        }  
        else  
        {  
        a[top]=item;  
        top++;  
        }  
      }  
      void pop()  
      {  
        if(top==0)   
        {  
         System.out.println("STACK EMPTY");   
        }  
        else  
        {  
          top--;  
          out=a[top];  
        }
    Get the Complete Code from http://c-madeeasy.blogspot.com/2011/...structure.html


  2. #2
    Junior Member Mrc0d3r's Avatar
    Join Date
    Jun 2011
    Location
    TCP/IP Layer 3
    Posts
    25
    My Mood
    Bored
    Thanks
    0
    Thanked 6 Times in 5 Posts

    Default Re: Implementation Stack Using Array

    You code..

    1.doesn't check for exceptions properly. Integer.parseInt() throws NumberFormatException

    2.violates sun java's naming conventions.

    How can you expect something like this to be a learning example ?
    Last edited by Mrc0d3r; August 20th, 2011 at 09:52 AM.

Similar Threads

  1. JAAS Implementation with JSF
    By mhwish in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: February 20th, 2010, 02:16 AM
  2. Stack Array..
    By qaromi in forum Collections and Generics
    Replies: 2
    Last Post: December 26th, 2009, 12:54 PM
  3. Interface Implementation
    By Samyx in forum Object Oriented Programming
    Replies: 1
    Last Post: December 2nd, 2009, 03:46 AM
  4. Help wih implementation...
    By Frank_nor in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 24th, 2009, 05:43 PM
  5. B+ Tree implementation
    By programmer in forum Java Theory & Questions
    Replies: 2
    Last Post: November 15th, 2009, 05:47 PM

Tags for this Thread