An exception is an unwanted event that breaks the standard flow of your program. Exceptions happen when you try to make an illegal operation. Let's explore a few examples. It is not possible to divide a number by zero. If you do this, your program will be stopped with an arithmetic exception. In the report from this exception, the name of this exception displays which is arithmetic exception, and also a message that informs you what went wrong. It also states, that you tried to divide a number by zero. Another line displays where the exception was thrown so that you can see that this exception happened in this function in line. Let's explore another example. When you try to read an integer from a string, you can use a method called two end from the string class. This method should transform this string 1, 2, 3 into an integer, 123. However, if you try to transform a text that is not an integer into an integer, it throws number format exception that contains information about what string you used. In all these cases, your program will not be able to continue when an exception occurs, so does this mean that any incorrectness in my code breaks the program? Definitely not. I can identify an exception and I can then stop it. To catch an exception, I use something called the try-catch block. I typed the try keyword followed by braces, and inside those braces, I include the code where I expect an exception to occur. I then include catch block. In this way, I will catch any throwable. It's called throwable since an exception is sometimes referred to as the throw statement, I then print caught. On the next line an exception should happen. I catch it using the catch block and then I print caught. The program continues and down is printed. Note that when an exception occurs, done was not printed because the exception broke the program. If the code is correct and does not throw an exception, catch is not executed. I just execute this code. I print 1, 2, 3 and then I print done, so this code is only executed when I catch an exception of a certain type. Inside catch, I can specify what kind of exception I would like to catch. The exception here is supposed to be number format exception. I can specify that we concretely expect such an exception by specifying a type in catch block. However, if you specify that you expect a different kind of exception than what you actually throw, it will not be caught so if you expect the arithmetic exception, and the exception thrown is number format exception, that is not an arithmetic exception and you will not catch it. This means that the program is broken again. Here an exception occurs and it is not caught by try-catch because its catch does not catch the exception that occurred, so the exception passes through and breaks our program. We can also have multiple catch blocks to cover multiple exception cases, so in the case of arithmetic exception, I will print caught arithmetic exception, and in the case of number format exception, I will print caught number format exception. There is a hierarchy of exceptions and at the top of this hierarchy there is throwable, which is a super type of all the exceptions, so if I catch throwable, I'm catching everything. The first catch will be chosen if I first catch throwable and then catch number format exception, it does not make sense because number format exception is a subtype of throwable. As throwable is the top of the hierarchy. It means that this catch will always catch all exceptions and the second catch will never work because it's placed in the next position. In this case, caught displays because throwable catches all the exceptions. However, if I reverse the order when number format exception happens, Caught number format exception displays, and if I choose arithmetic exception caught displays, you also have this variable in the catch function that you can name whenever you want. It is typically E, but it can be any other name, like error or exception or number format exception. This is a reference to the exception and you can use that to print this exception. You can also use it to learn something about this exception, read a message of this exception or some other characteristics of this exception. It can, for example, display where this exception has happened.