Java Generic Stack User
import java.io.*; import java.util.*; public class stktst { public static void main(String [] args) { // Make a stack of Integers. Stack<Integer> is = new Stack<>(30); System.out.print("Enter integers to -1:\n> "); BufferedReader bufferedReader = new BufferedReader (new InputStreamReader(System.in)); try { int n = Integer.parseInt(bufferedReader.readLine().trim()); while(n != -1) { is.push(n); System.out.print("> "); n = Integer.parseInt(bufferedReader.readLine().trim()); } } catch(IOException e) { } while(!is.empty()) System.out.print(is.pop() + " "); System.out.println(); // Make a stack of strings. Stack<String> ss = new Stack<>(50); System.out.print("Enter lines to blank:\n> "); try { String s = bufferedReader.readLine(); while(!s.equals("")) { ss.push(s); System.out.print("> "); s = bufferedReader.readLine(); } } catch(IOException e) { } System.out.println(); while(!ss.empty()) System.out.println(ss.pop() + " "); } }