Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Iterating & Adding to a Stack

// Java code to illustrate hashCode()

import java.util.*;

public class StackDemo {
	public static void main(String args[])
	{
		// Creating an empty Stack
		Stack<Integer> stack
			= new Stack<Integer>();

		// Use add() method
		// to add elements into the Stack
		stack.add(10);
		stack.add(20);
		stack.add(30);
		stack.add(40);
		stack.add(50);

		// Displaying the Stack
		System.out.println("Stack: " + stack);

		// Creating an iterator
		Iterator value = stack.iterator();

		// Displaying the values
		// after iterating through the stack
		System.out.println("The iterator values are: ");
		while (value.hasNext()) {
			System.out.println(value.next());
		}
	}
}
Comment

PREVIOUS NEXT
Code Example
Java :: android string animation 
Java :: code to close dialog containg layout 
Java :: Java @FunctionalInterface annotation 
Java :: android bootom app bar tab bar 
Java :: Kotlin const to Java 
Java :: change order of words in string java 
Java :: how to call values from methods in flutter 
Java :: how to mutate value in vector in java 
Java :: jbutton scroll list full width size 
Java :: mei mei bad 
Java :: diamonds 
Java :: @parameters on test use jupyter junit api 
Java :: okhttp Synchronous Network Calls 
Java :: signed and unsigned data types in java 
Java :: Changing or Replacing Elements in java map 
Java :: how to print message to console java 
Java :: why fields should be final in immutable class? 
Java :: a Java-8 stream of batches, 
Java :: antlr TestRig in java program 
Java :: java tcp readline not working 
Java :: Arraylist imp for recursion 
Java :: What Is Spring Boot and What Are Its Main Features? 
Java :: how to read returned arraylist from another class method 
Java :: exception(string message throwable cause) 
Java :: password = sdf345 password.isalpha() java 
Java :: Java Program to Print Spiral Pattern of Numbers 
Java :: store files system in tree java 
Java :: android studio enum usage 
Java :: set bean properties 
Java :: Java socket connect to gmail 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =