

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
While working with Java in eclipse I got a warning saying "dead code". What does it mean?
A code block/statement in Java to which the control never reaches and never gets executed during the lifetime of the program is known as unreachable block/statement.
public class UnreachableCodeExample { public String greet() { System.out.println("This is a greet method "); return "Hello"; System.out.println("This is an unreachable code "); } public static void main(String args[]) { new UnreachableCodeExample().greet(); } }
Dead code
A dead code is an unreachable code, but it doesn’t generate compile time error. But if you execute it in eclipse it gives you a warning.
Example
In the following Java program
public class UnreachableCodeExample { public void greet() { System.out.println("This is the greet method "); if(true){ return; } System.out.println("This is a dead code "); } public static void main(String args[]) { new UnreachableCodeExample().greet(); } }
Output
This is the greet method
If you run the same program in eclipse it raises a warning as −
- Related Questions & Answers
- What is a lunar eclipse? When does it occur?
- "Makkal Needhi Maiam" what does it mean?
- What does it mean when a numeric constant in C/C++ is prefixed with a 0?
- Is it mandatory to register the driver while working with JDBC?
- What does it mean by select 1 from MySQL table?
- What are the rules to be followed while working with a switch statement in java?
- Is it true that Subrata Roy got VIP treatment while he was in Jail?
- What does these operators mean (** , ^ , %, //) ?
- What does createdCollectionAutomatically mean in MongoDB?
- What does operator ~= mean in Lua?
- What does # mean in Lua programming?
- What does series mean in pandas?
- How can I earn well while working from home?
- What does “unsigned” in MySQL mean and when to use it?
- What does the slash mean in a MySQL query?
Advertisements