Appendix E Solutions to Programming Exercises
1 Basics of Java Programming
1.1 The printStackElements()
method of the PrintableCharStack
class does not pop the elements.
//Filename: PrintableCharStack.javapublic class PrintableCharStack extends CharStack { // (1) // Instance method public void printStackElements() { // (2) for (int i = 0; i <= topOfStack; i++) System.out.print(stackArray[i]); // print each char on terminal System.out.println(); } // Constructor calls the constructor of the superclass explicitly. PrintableCharStack(int capacity) { super(capacity); } // (3)}//Filename: Client.javapublic class Client { public static void main(String[] args) { ...
Get A Programmer’s Guide to Java™ SCJP Certification: A Comprehensive Primer, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.