Wrox Articles

Beginning Java Programming: The Object-Oriented Approach Chapter 6 Logger Class

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This example demonstrates how to use Java’s Logger class to log messages to the screen or file. Run the program and then open the files loggerExample_config.log (see the tree of project files to the left of the code window) to […]

Tags:

Beginning Java Programming: The Object-Oriented Approach Chapter 6 Different Assert Functions in JUnit

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This example demonstrates how to use different assert functions in your JUnit code. Click “Run” to run the example in your browser or edit the code and then click “Run” to run it with your changes. You can download the […]

Tags:

Beginning Java Programming: The Object-Oriented Approach Chapter 6 Empty JUnit Testcase

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This program demonstrates an empty JUnit testcase. Notice the fail() function called on line 29. That is the function that throws the AssertionError that is printed on the screen when the program is run. Click “Run” to run the example […]

Tags:

Beginning Java Programming: The Object-Oriented Approach Chapter 6 ArrayIndexOutOfBoundsException

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This program throws an ArrayIndexOutOfBoundsException because the for loop is trying to access more elements than are actually present in the array. To get it working properly, change the comparison operator “<=" to "<" on line 7. Now the program […]

Tags:

Beginning Java Programming: The Object-Oriented Approach Chapter 6 Displaying an Unintialized Object Member

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This example demonstrates what happens when an object member is displayed without being initialized. The program displays “null” for the value of myPerson.name. Click “Run” to run the example in your browser or edit the code and then click “Run” […]

Tags:

Beginning Java Programming: The Object-Oriented Approach Chapter 6 Using a Custom Object Prior to Initialization

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This example demonstrates what happens when you try to use a custom object without initializing it first. You will get a compiler error when you run this program, informing you that the variable employee has not been initialized before it […]

Tags:

Beginning Java Programming: The Object-Oriented Approach Chapter 6 Finally Keyword and Try-Catch

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This example demonstrates how to use the finally keyword with try-catch blocks. The code in the finally block will always be executed when the try-catch block exits. Click “Run” to run the example in your browser or edit the code […]

Tags:

Beginning Java Programming: The Object-Oriented Approach Chapter 6 Catching Exceptions Using Throwable interface

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This example demonstrates how to catch any type of exception by using the Throwable interface. Click “Run” to run the example in your browser or edit the code and then click “Run” to run it with your changes. You can […]

Tags:

Beginning Java Programming: The Object-Oriented Approach Chapter Catching 2 Exceptions with 1 Try

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This example demonstrates how to catch two types of exceptions using only one try block. The program catches exceptions of types ArithmeticException and NullPointerException while using a single try block. Click “Run” to run the example in your browser or […]

Tags:

Beginning Java Programming: The Object-Oriented Approach Chapter 6 Catching 2 Exceptions

This is the live code sandbox for Beginning Java Programming: The Object-Oriented Approach Chapter 6. This example demonstrates how to catch two types of exception using a single line of code. The program catches exceptions of types ArithmeticException or NullPointerException using the code on line 15. Click “Run” to run the example in your browser […]

Tags: