Sitemap

Member-only story

throw vs throws vs Throwable In Java – Explained with Examples

4 min readApr 6, 2025

🔒 This is a Medium member-only article. If you’re not a Medium member, you can read the full article for free on my blog: throw vs throws vs Throwable In Java.

In Java exception handling, three commonly confused terms are: throw, throws, and Throwable. At first glance, these keywords and class names may seem related because they all deal with exceptions, but each plays a very different role.

If you’re new to Java or preparing for interviews, it’s essential to understand how throw, throws, and Throwable work — and when to use each one correctly.

In this article, we’ll break down these three concepts with simple language, real code examples, and a comparison table to help you master Java exception handling.

📌 Quick Summary

Let’s now explore each one in detail.

🚀 1. What is throw in Java?

The throw keyword is used in Java to manually throw an exception. You can throw either checked or unchecked exceptions using throw.

Syntax:

throw new ExceptionType("Error message");

Example:

public class ThrowExample {
public static void main(String[] args) {…

--

--

No responses yet