stack_in_java
// Java code for stack implementation package com.company ; import java.io. *; import java.util. *; class stack { // Pushing element on the top of the stack static void stack_push ( Stack < Integer > stack ) { for ( int i = 0 ; i < 5 ; i ++) { stack . push ( i ); } } // Popping element from the top of the stack static void stack_pop ( Stack < Integer > stack ) { System . out . println ( "Pop Operation:" ); for ( int i = 0 ; i < 5 ; i ++) { Integer y = ( Integer ) stack . pop (); System . out . println ( y ); } } // Displaying element on the top of the stack static void stack_peek ( Stack < Integer > stack ) { Integer element = ( Integer ) stack . peek (); System . out . println ( "Element on stack top: " + element ); } // Searching element in the stack static void stack_search ( ...
Comments
Post a Comment