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.toVidya3h 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
1 views

Related Articles

News

The Tooling Layer. What Sits Around Models and Why It Matters.

Medium Programming • 3h ago

News

FlowG - Road to 1.0

Lobsters • 4h ago

Kia shows off small cars in NY: The 2027 EV3 and 2027 Seltos Hybrid
News

Kia shows off small cars in NY: The 2027 EV3 and 2027 Seltos Hybrid

Ars Technica • 4h ago

The New Era of Militia Influencers
News

The New Era of Militia Influencers

Wired • 4h ago

This Android camera accessory helped me spot a hidden electrical hazard just in time
News

This Android camera accessory helped me spot a hidden electrical hazard just in time

ZDNet • 5h ago

Discover More Articles