Driver program
public static void main ( String [ ] args ) { Stack < Integer > s = new Stack < Integer > ( ) ; s . push ( 4 ) ; s . push ( 5 ) ; s . push ( - 2 ) ; s . push ( - 3 ) ; s . push ( 11 ) ; s . push ( 10 ) ; s . push ( 5 ) ; s . push ( 6 ) ; s . push ( 20 ) ; if ( pairWiseConsecutive ( s ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; System . out . println ( " Stack ▁ content ▁ ( from ▁ top ) ▁ after ▁ function ▁ call " ) ; while ( s . isEmpty ( ) == false ) { System . out . print ( s . peek ( ) + " ▁ " ) ; s . pop ( ) ; } } }