- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between throw and throws keywords in Java?
The throw keyword is used to raise an exception explicitly.
Example
public class Test { public static void main(String[] args) { throw new NullPointerException(); } }
Exception in thread "main" java.lang.NullPointerException at a6.dateAndTime.Test.main(Test.java:5)
The throws keywords in Java used to postpone the handling of a checked exception.
public class Test { public static void main(String[] args)throws NullPointerException { throw new NullPointerException(); } }
- Related Articles
- Difference between throw and throws in Java
- Throw and throws in Java
- Try, catch, throw and throws in Java
- What is the difference between keywords and reserved words in Java?
- What is the difference between super and this, keywords in Java?
- What is the difference between throw e and throw new Exception(e) in catch block in java?
- Difference Between extends and implements keywords in Java
- What is the difference between keywords const and readonly in C#?
- What is the difference between VAR and DYNAMIC keywords in C#?
- Is it possible to throw exception without using "throws Exception" in java?
- What is the difference between public, static and void keywords in C#?
- What is the difference between 'throw new Error' and 'throw someObject' in javascript?
- Try/catch/finally/throw keywords in C#
- Explain the difference between const and readonly keywords in C#
- What is the difference between Java and Core Java?

Advertisements