- 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 try block in Java?
A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch looks like the following –
Syntax
try { // Protected code } catch (ExceptionName e1) { // Catch block }
The code which is prone to exceptions is placed in the try block. When an exception raised inside a try block, instead of terminating the program JVM stores the exception details in the exception stack and proceeds to the catch block.
- Related Articles
- Can we declare a try catch block within another try catch block in Java?
- Is it necessary that a try block should be followed by a catch block in Java?
- Can we have a try block without a catch block in Java?\n
- Can a try block have multiple catch blocks in Java?
- What is the catch block in Java?
- What is the finally block in Java?
- What is try-with-resource in java?
- Can we define a try block with multiple catch blocks in Java?
- Is it possible to have multiple try blocks with only one catch block in java?
- Explain Try/Catch/Finally block in PowerShell
- Why we can't initialize static final variable in try/catch block in java?
- What are try, catch, finally blocks in Java?
- Can we write code in try/catch block in JSP as well?
- What are block lambda expressions in Java?
- The Initializer Block in Java

Advertisements