Jump to content

Java Stack sample

- - - - -

  • Please log in to reply
No replies to this topic

#1
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts
Simple sample of stacks that might be useful?
100=>1
import java.util.Stack;

public class stack {


	public static void main(String[] arg) {

		Stack<Integer> s1 = new Stack<Integer>();

		for(int i = 1; i<=100; i++) {

		s1.push(new Integer(i));	

		}

		while(!s1.empty()) {

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

		}

		System.out.println("\n"+"This was from 100=>1");

	}

}


Posted Image




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users