java stack peek
// Java code to illustrate peek() function
import java.util.*;
public class StackDemo {
public static void main(String args[])
{
// Creating an empty Stack
Stack<String> STACK = new Stack<String>();
// Use push() to add elements into the Stack
STACK.push("Welcome");
// Fetching the element at the head of the Stack
System.out.println("The element at the top of the"
+ " stack is: " + STACK.peek());
// Displaying the Stack after the Operation
System.out.println("Final Stack: " + STACK);
}
}
Also in Java:
- converting char array to string
- java convert string with commas to long
- money value commas java
- java random number between 100 and 999
- processing string to int
- iterator loop java
- java swing change label icon
- math max java
- how to exit a for loop in java
- Unhandled exception: java.lang.InterruptedException
- java create directory
- java hashmap get value
- how to get the width and height of a string in java
- imageview.setbackground
- Java use Base64
- write an object java in a file
- java stream filter
- convert int array to integer list java
- java stack peek
- java get icon for file type
- difference between java and javascript
- index of an array procesing
- print int in java
- java arraylist to array