What is the meaning of error "unreachable statement "? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the meaning of error "unreachable statement "?

16th Jun 2018, 7:17 PM
Sarvesh Chaudhary
Sarvesh Chaudhary - avatar
7 Answers
+ 3
Sarvesh Chaudhary Some suggestions: Look at the code preceding the unreachable statement: - maybe it is within a if or while loop where the condition is always false? - maybe it is within a if or while loop but after a break or continue? - maybe it is after an infinite loop? Look at the variables: if their value never changes but they are used for if, while or switch blocks, you may have unreachable statements. Also look at the return, break and exit statements: The code after those statement is unreachable
17th Jun 2018, 4:33 AM
ifl
ifl - avatar
+ 3
Unreachable statement means there is a line of code that will never be executed. For example, some code after a "return" in a function.
16th Jun 2018, 7:20 PM
ifl
ifl - avatar
+ 2
Sarvesh Chaudhary can you share a code with us so that we can help you..
16th Jun 2018, 8:10 PM
Arun Tomar
Arun Tomar - avatar
+ 1
thanks but I have not defined my own function I have written all program in main method
16th Jun 2018, 7:24 PM
Sarvesh Chaudhary
Sarvesh Chaudhary - avatar
+ 1
could also be in an if or have something to do with the placement of the break or continue statement
16th Jun 2018, 7:34 PM
Max
Max - avatar
+ 1
I can but its too long
17th Jun 2018, 1:57 AM
Sarvesh Chaudhary
Sarvesh Chaudhary - avatar
+ 1
Thank you very much. ifl ☺
18th Jun 2018, 6:40 AM
Sarvesh Chaudhary
Sarvesh Chaudhary - avatar