-
Book Overview & Buying
-
Table Of Contents
Java Coding Problems - Second Edition
By :
Use the following problems to test your programming prowess on Objects, immutability, switch expressions, and pattern matching. I strongly encourage you to give each problem a try before you turn to the solutions and download the example programs:
IndexOutOfBoundsException.toString() or hashCode().@snippet tag.Proxy instances: Write several programs that invoke interface default methods from Proxy instances in JDK 8, JDK 9, and JDK 16.-Xlint:missing-explicit-ctor.isEmpty(), push(), pop(), and peek() operations).String immutability characteristic).NullPointerException and explain how JDK 14 improves NPE messages.yield keyword with switch expressions in JDK 13+.null values in switch expressions (including JDK 17+ approaches).equals() is different from the == operator.instanceof operator. instanceof.instanceof.equals() (including for generic classes) before and after type patterns for instanceof have been introduced.instanceof and generics.instanceof and the Stream API together? If yes, provide at least an example. instanceof but are also available for switch. Provide here the theoretical headlines and an example of this topic.switch for JDK 17 and 21.switch is a cool feature, so exemplify it here in a comprehensive approach with plenty of examples.switch expressions. Explain and exemplify it in detail (theory ad examples).null values are handled by unconditional patterns of switch expressions before and after JDK 19.The following sections describe solutions to the preceding problems. Remember that there usually isn’t a single correct way to solve a particular problem. Also remember that the explanations shown here include only the most interesting and important details needed to solve the problems. Download the example solutions to see additional details and to experiment with the programs at https://github.com/PacktPublishing/Java-Coding-Problems-Second-Edition/tree/main/Chapter02.