FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Exception Handling Keywords in Java
NewsMachine Learning

Exception Handling Keywords in Java

via Dev.toVidya2d ago

What is an Exception? An exception is an unwanted event that occurs during program execution. Example: Dividing a number by zero Accessing null object File not found 1. try Block The try block contains code that may cause an exception. Syntax: try { // risky code } Example: try { int a = 10 / 0 ; // exception } Where we use: --> Database operations --> File handling --> Network calls 2. catch Block The catch block handles the exception thrown in the try. Syntax: catch(Exception e) { // handling code } Example: try { int a = 10 / 0 ; } catch ( ArithmeticException e ) { System . out . println ( "Cannot divide by zero" ); } Where we use: --> To show user-friendly messages --> To prevent program crash 3. finally Block The finally block always executes whether an exception occurs or not. Syntax: finally { // cleanup code } Example: try { int a = 10 / 2 ; } catch ( Exception e ) { System . out . println ( "Error" ); } finally { System . out . println ( "Always executed" ); } Real-time use: -

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles

Official White House app developer also a UFO conspiracy theorist
News

Official White House app developer also a UFO conspiracy theorist

Ars Technica • 2d ago

The Artemis Moon base project is legally dubious
News

The Artemis Moon base project is legally dubious

The Verge • 2d ago

The HP OmniBook 5 Is a MacBook Neo Killer, and It's Only $500
News

The HP OmniBook 5 Is a MacBook Neo Killer, and It's Only $500

Wired • 2d ago

Trump defunding of NPR and PBS blocked by judge, but damage is already done
News

Trump defunding of NPR and PBS blocked by judge, but damage is already done

Ars Technica • 2d ago

Everything is iPhone now
News

Everything is iPhone now

The Verge • 2d ago

Discover More Articles