Handling Errors: Handling Exceptions in Java

Java    |    Beginner
  • 8 videos | 1h 9m 40s
  • Includes Assessment
  • Earns a Badge
Rating 4.6 of 27 users Rating 4.6 of 27 users (27)
It is important to handle exceptions proactively in Java to ensure that the flow of a program doesn't break on the occurrence of an exception. Take this course to explore the fundamentals of handling exceptions and different constructs available in Java that allow you to do so. Delve into working with try-catch, finally, and try-with-resource blocks to handle various exceptions within your code. These blocks can be used to catch single, multiple, or categories of exceptions, clean up after your code has run, and handle exceptions related to specific Java objects, respectively. Upon completion of this course, you'll be able to implement exception handling within Java effectively.

WHAT YOU WILL LEARN

  • Discover the key concepts covered in this course
    Recognize how the throwing of exceptions influences the flow of a java program
    Implement a basic try-catch block to handle an exception in java
    Use multiple catch blocks to handle different types of exceptions in your code
  • Use a finally block to clean up after code execution in a try-catch
    Use the throws keyword in a method signature instead of implementing an exception handler
    Implement a try-with-resource block to close resources after their use
    Summarize the key concepts covered in this course

IN THIS COURSE

  • 2m 18s
    In this video, you’ll learn more about your instructor and this course. In this course, you’ll learn the fundamentals of exception handling and the different constructs available in Java to achieve this end. You’ll implement a try-catch block and learn how try-catch blocks can be used to catch single, multiple, and categories of exceptions. You’ll use finally blocks to clean up after your code has run. Finally, you’ll implement a try with resource block. FREE ACCESS
  • 8m 31s
    In this video, you’ll watch a demo. You’ll explore exception handling and learn the flow of a program when an exception is thrown. Onscreen, you’ll see a new source file called HandlingExceptions.java has been within the project. You’ll now paste in some code. You’ll see there’s an array of double values onscreen. The variable called index has been initialized. There are also three different print statements included. FREE ACCESS
  • Locked
    3.  Handling Java Exceptions
    9m 49s
    In this video, you’ll watch a demo. You’ll take a deeper look at the exception object. First, you’ll clear the console. Then, you’ll introduce a new try catch block. Inside the try block you have the same line as before with the invocation of System.out.format which will throw an exception. In the catch block you’ll explore different methods available for an exception object. FREE ACCESS
  • Locked
    4.  Tackling Multiple Exceptions in Java
    12m 47s
    In this video, you’ll watch a demo. You’ll explore how it’s possible to define multiple handlers by creating several catch blocks for each try block. You’ll see a new MultipleExceptions class has been created. You’ll see there are two types of exceptions that can be thrown. First, thought, you’ll take a look at what the code contains. You’ll see you have a starting print statement at the top. FREE ACCESS
  • Locked
    5.  Using the finally Block in Java
    12m 52s
    In this video, you’ll watch a demo. You’ll learn to work with the finally block. This is something included at the end of a try-catch block. It’s executed whether or not an exception is thrown. Onscreen, you’ll see a new class called FinallyBlock has been created within a new source file here. One common use case of the FinallyBlock is to close out any resources that have been consumed during the code execution. FREE ACCESS
  • Locked
    6.  Working with the throws Keyword in Java
    10m 58s
    In this video, you’ll watch a demo. You’ll explore other cases of the throws keyword and see how it can be applied when you have recursive function calls. You’ll see a new source file has been created. It’s a new class called ThrowsKeyword. You’ll begin by adding in some code. This code will be similar to what you’ve already worked with. You’ll import a BufferedReader, File, and FileReader to read from a file. FREE ACCESS
  • Locked
    7.  Implementing the try-with-resource Block in Java
    10m 23s
    In this video, you’ll watch a demo. In this demo, you’ll learn how the closing of a resource after it has been used can be made more concise using a TryWithResourcesBlock. If you have a background in Python programming, you’ll see this is Java's equivalent of the width block. You’ll see a new source file has been created, as well as a class called TryWithResourcesBlock. FREE ACCESS
  • Locked
    8.  Course Summary
    2m 3s
    In this video, you’ll summarize what you’ve learned in this course. You’ve learned to implement a try-catch block. You also covered how try-catch blocks can be used to catch single, multiple, or categories of exceptions. You also learned the hierarchy of exception classes in Java and how this can be used to define your own exception handlers. You also used finally blocks to clean up after your code has run, whether an exception was thrown. FREE ACCESS

EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE

Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.

Digital badges are yours to keep, forever.

YOU MIGHT ALSO LIKE

Rating 4.4 of 34 users Rating 4.4 of 34 users (34)
Rating 4.5 of 18 users Rating 4.5 of 18 users (18)

PEOPLE WHO VIEWED THIS ALSO VIEWED THESE

Rating 4.5 of 48 users Rating 4.5 of 48 users (48)
Rating 4.3 of 18 users Rating 4.3 of 18 users (18)
Rating 4.4 of 38 users Rating 4.4 of 38 users (38)