#77 Exception Handling Using try catch in Java

Telusko January 19, 2023
Video Thumbnail
Telusko Logo

Telusko

@telusko

About

Hey Aliens Welcome to Telusko! We create technical tutorials that take you from beginner to advanced level. You’ll find content on: Core Programming: Java (Beginner to Advanced), Python, JavaScript Frameworks & Tools: Spring Framework, Hibernate, Blockchain, Spring AI, AI Engineering Computer Science Essentials: Data Structures, Networking, System Design, and more Trending Tech: Cloud, Microservices, and beyond Alongside technical tutorials, we also share motivational videos and host sessions with leading industry experts. We don’t just stop at free tutorials—we also provide paid courses (live and recorded) and corporate training to help professionals and organizations upskill. So, whether you’re just starting out or sharpening your professional skills, there’s always something here for you. 📩 Business Inquiries: [email protected] 🎓 Explore Live & Recorded Courses: https://telusko.com/

Video Description

Check out our courses: Java Spring Boot AI Live Course: https://go.telusko.com/JavaSpringBootAI Coupon: TELUSKO20 (20% Discount) AI Powered DevOps with AWS - Live Course :- https://go.telusko.com/AIDevOps-AWS Coupon: TELUSKO20 (20% Discount) Master Java Spring Development : https://go.telusko.com/masterjava Coupon: TELUSKO20 (20% Discount) For More Queries WhatsApp or Call on : +919008963671 website : https://courses.telusko.com/ Udemy Courses: Spring: https://go.telusko.com/udemyteluskospring Java:- https://go.telusko.com/udemyteluskojava Java Spring:- https://go.telusko.com/Udemyjavaspring Java For Programmers:- https://go.telusko.com/javaProgrammers Python : https://go.telusko.com/udemyteluskopython Git : https://go.telusko.com/udemyteluskogit Docker : https://go.telusko.com/udemyteluskodocker Instagram : https://www.instagram.com/navinreddyofficial/ Linkedin : https://in.linkedin.com/in/navinreddy20 TELUSKO Android App : https://go.telusko.com/TELUSKOAPP TELUSKO IOS App : https://apple.co/3SsgmU2 Discord : https://discord.gg/D8hWe9BqfF In this lecture we are discussing how to handle exception using try-catch: -- Exception handling is a mechanism in Java that allows developers to handle and recover from errors and exceptional conditions that may occur during the execution of a program. -- One way to handle exceptions in Java is by using the try-catch block. General Syntax of try -catch to handle exception: try { // code that may throw an exception } catch (ExceptionType1 e1) { // code to handle the exception of type ExceptionType1 } catch (ExceptionType2 e2) { // code to handle the exception of type ExceptionType2 } finally { // optional block of code that is executed regardless of whether an exception was thrown or not } we will discussing about everything try, catch ,finally and ExceptionType one by one -- in this lecture we are only deal with single catch statement with try // try to handle the exception class Main{ public static void main(String[] args) { int i=4; //normal statement try{ int a = 10/0; //critical statement /*Not handling excpetion then if you not handle the exception then it will be thrown to the JVM and JVM will terminate the program abnormally and it will not execute the remaining statements */ /* if you handle the exception then it will not be thrown to the JVM and JVM will not terminate the program abnormally and it will execute the remaining statements */ }catch(Exception e){ System.out.println("Some exception occured"); } System.out.println("We are coming out of the try catch block successfully"); } } -- In the above code, the try block contains the code that may throw an exception. The catch block catches the exception of a specific type and handles it. -- statemtns of two types i)normal statements Normal Statements: Normal statements are statements that do not require any special handling, and they are executed in a normal sequence. e.g Variable declarations and assignments: These statements are used to declare and assign values to variables. ii)critical statements Critical statements are statements that can cause an exception or error, and they require special handling. Handle using : throw statements: These statements are used to throw an exception. try-catch statements: These statements are used to handle exceptions. finally statements: These statements are used to specify a block of code that is always executed, whether an exception is thrown or not. Github repo : https://github.com/navinreddy20/Javacode.git More Learning : Java :- https://bit.ly/3x6rr0N Python :- https://bit.ly/3GRc7JX Django :- https://bit.ly/3MmoJK6 JavaScript :- https://bit.ly/3tiAlHo Node JS :- https://bit.ly/3GT4liq Rest Api :-https://bit.ly/3MjhZwt Servlet :- https://bit.ly/3Q7eA7k Spring Framework :- https://bit.ly/3xi7buh Design Patterns in Java :- https://bit.ly/3MocXiq Docker :- https://bit.ly/3xjWzLA Blockchain Tutorial :- https://bit.ly/3NSbOkc Corda Tutorial:- https://bit.ly/3thbUKa Hyperledger Fabric :- https://bit.ly/38RZCRB NoSQL Tutorial :- https://bit.ly/3aJpRuc Mysql Tutorial :- https://bit.ly/3thpr4L Data Structures using Java :- https://bit.ly/3MuJa7S Git Tutorial :- https://bit.ly/3NXyCPu Donation: PayPal Id : navinreddy20 https://www.telusko.com

Indulge in Luxury Living

AI-recommended products based on this video

Loading...
OCKYOOZ 4 Tier Folding Ladder Chair, 3-in-1 Solid Wood Step Ladder, Foldable Ladder Stool Shelf, Protable 4-Step Library Ladder, Multi-Functional Display Stand for Home Office (Size:14"L*18"D*35.4"H)

OCKYOOZ 4 Tier Folding Ladder Chair, 3-in-1 Solid Wood Step Ladder, Foldable Ladder Stool Shelf, Protable 4-Step Library Ladder, Multi-Functional Display Stand for Home Office (Size:14"L*18"D*35.4"H)

(3)
$119.99
FREE delivery Sat, Jun 28
Loading...
ARZOPA Portable Monitor, 16.1" FHD 1080P Kickstand 100% sRGB High Color Gamut Portable Laptop Monitor IPS Eye Care Screen for High-end Office & Entertainment - Z1C

ARZOPA Portable Monitor, 16.1" FHD 1080P Kickstand 100% sRGB High Color Gamut Portable Laptop Monitor IPS Eye Care Screen for High-end Office & Entertainment - Z1C

(2,728)
$129.99
FREE delivery Tue, Aug 12
100+ bought in past month
Loading...
Smart Hydroponics Growing System, LetPot 12 Pods Indoor Garden, 24W Light, App&WiFi Control, Water Shortage Remind, 20" Adjustable Rod, 5.5L Tank, Herb Garden for Home Kitchen, Stainless Steel
Amazon's Choice

Smart Hydroponics Growing System, LetPot 12 Pods Indoor Garden, 24W Light, App&WiFi Control, Water Shortage Remind, 20" Adjustable Rod, 5.5L Tank, Herb Garden for Home Kitchen, Stainless Steel

(1,781)
$139.99
PrimeFREE delivery Sat, Jun 14
50+ bought in past month
Loading...
YOTON Y3 Mini Portable Movie Projector, 1080P Full HD Supported, Outdoor Home Movie Theater Projector, Compatible with Fire TV Stick, HDMI, USB, PS5, Xbox, iOS, Android, Laptop

YOTON Y3 Mini Portable Movie Projector, 1080P Full HD Supported, Outdoor Home Movie Theater Projector, Compatible with Fire TV Stick, HDMI, USB, PS5, Xbox, iOS, Android, Laptop

(393)
$46.59$34.94
PrimeFREE delivery Sat, Jun 14
300+ bought in past month
Loading...
Multitool Camping Accessories 17 in 1 Fire Starting Sticks, Bottle Opener, Saw Screwdrivers Bottle Opener, Whistle, Window Breaker and More -Perfect for Camping, Outdoor, Survival, Gifts for Men Dad

Multitool Camping Accessories 17 in 1 Fire Starting Sticks, Bottle Opener, Saw Screwdrivers Bottle Opener, Whistle, Window Breaker and More -Perfect for Camping, Outdoor, Survival, Gifts for Men Dad

(1,711)
$29.89
FREE delivery Thu, Jun 19 on your first order
200+ bought in past month
Loading...
Waterdrop 10UA Under Sink Water Filter System, Reduces Lead, Chlorine, Bad Taste & Odor, Under Counter Water Filter Direct Connect to Kitchen Faucet, NSF/ANSI 42 Certified, 8K Gallons, USA Tech

Waterdrop 10UA Under Sink Water Filter System, Reduces Lead, Chlorine, Bad Taste & Odor, Under Counter Water Filter Direct Connect to Kitchen Faucet, NSF/ANSI 42 Certified, 8K Gallons, USA Tech

(19,655)
$69.99
FREE delivery Tue, Sep 23
100+ bought in past month
Loading...
Waterdrop 15UA Under Sink Water Filter System, Reduces Lead, Chlorine, Bad Taste & Odor, Under Counter Water Filter Direct Connect to Kitchen Faucet, NSF/ANSI 42 Certified, 16000 Gallons, USA Tech
Amazon's Choice

Waterdrop 15UA Under Sink Water Filter System, Reduces Lead, Chlorine, Bad Taste & Odor, Under Counter Water Filter Direct Connect to Kitchen Faucet, NSF/ANSI 42 Certified, 16000 Gallons, USA Tech

(9,244)
$87.99$79.99
FREE delivery Tue, Sep 23
700+ bought in past month
Loading...
Waterdrop 17UA 3 Years Under Sink Water Filter System-Reduces Lead, Chlorine, Bad Taste & Odor-Under Counter Water Filter Direct Connect to Kitchen Faucet-NSF/ANSI 42 Certified-24000 Gallons-USA Tech

Waterdrop 17UA 3 Years Under Sink Water Filter System-Reduces Lead, Chlorine, Bad Taste & Odor-Under Counter Water Filter Direct Connect to Kitchen Faucet-NSF/ANSI 42 Certified-24000 Gallons-USA Tech

(2,977)
$99.99
FREE delivery Tue, Sep 23
100+ bought in past month
Loading...
YOTON Y3 Mini Portable Movie Projector, 1080P Full HD Supported, Outdoor Home Movie Theater Projector, Compatible with Fire TV Stick, HDMI, USB, PS5, Xbox, iOS, Android, Laptop

YOTON Y3 Mini Portable Movie Projector, 1080P Full HD Supported, Outdoor Home Movie Theater Projector, Compatible with Fire TV Stick, HDMI, USB, PS5, Xbox, iOS, Android, Laptop

(393)
$46.59$34.94
PrimeFREE delivery Sat, Jun 14
300+ bought in past month
Loading...
AeroGarden Harvest Indoor Garden Hydroponic System with LED Grow Light and Herb Kit, Holds up to 6 Pods, Black

AeroGarden Harvest Indoor Garden Hydroponic System with LED Grow Light and Herb Kit, Holds up to 6 Pods, Black

(5,204)
$89.00
PrimeFREE delivery Sat, Jun 14
Loading...
AeroGarden Harvest Elite 360 Indoor Garden Hydroponic System with LED Grow Light and Herb Kit, Holds up to 6 Pods, Stainless

AeroGarden Harvest Elite 360 Indoor Garden Hydroponic System with LED Grow Light and Herb Kit, Holds up to 6 Pods, Stainless

(1,193)
$46.80$42.12
PrimeFREE delivery Sat, Jun 14
100+ bought in past month
Loading...
Crownow 64Pods Hydroponics Growing System,Herb Garden Indoor Kit with LED Grow Light,Large Capacity Hydroponic Tower Indoor Garden System for Vegetables Fruits Herbs

Crownow 64Pods Hydroponics Growing System,Herb Garden Indoor Kit with LED Grow Light,Large Capacity Hydroponic Tower Indoor Garden System for Vegetables Fruits Herbs

(1)
$479.99
PrimeFREE delivery Sat, Jun 14
Loading...
Environet Hydroponic Growing Kit, Self-Watering Mason Jar Herb Garden Starter Kit Indoor, Windowsill Herb Garden, Grow Your Own Herbs from Organic Seeds (Basil)

Environet Hydroponic Growing Kit, Self-Watering Mason Jar Herb Garden Starter Kit Indoor, Windowsill Herb Garden, Grow Your Own Herbs from Organic Seeds (Basil)

(786)
$69.15$33.51
FREE delivery Jun 13 - 17