-4

This is the line which is showing error. i am using netbeans ide for coding

   localIterator2 = Collections.list(inetAddresses).iterator(); 
   continue; 
   InetAddress inetAddress = (InetAddress)localIterator2.next();

The ERROR IS UNREACHABLE Statement The Assigned Value is never used Please help ... please correct this line of code :/

  • 3
    @ user2224966 : Please spend some time in asking good questions – Jayan Mar 29 '13 at 16:00
  • No error? Rename the title and change the question accordingly. – asgs Mar 29 '13 at 16:01
  • @ColinD it shows that an error has occurred and an option Run anyway – user2224966 Mar 29 '13 at 16:03
  • @Jayan dude m a beginner pls help – user2224966 Mar 29 '13 at 16:03
  • @ColinD The Error is Unreachable statement – user2224966 Mar 29 '13 at 16:06
  • @asgs Error Unreachable statement – user2224966 Mar 29 '13 at 16:07
  • 1
    @ user2224966 : http://stackoverflow.com/faq#etiquette, http://meta.stackexchange.com/questions/18584/how-to-ask-a-smart-question – Jayan Mar 29 '13 at 16:07
  • @user2224966 You will need to show, at least, the error log and some of the code that pertains to the references (variable names) in the line that causes the error, i.e. the code leading into the error and perhaps the class definitions of each variable type, before anyone can begin to answer the question. – Nolo Mar 29 '13 at 16:09
  • 2
    @user2224966 This might help you [--->Why does Java have an “unreachable statement” compiler error?](http://stackoverflow.com/questions/3795585/why-does-java-have-an-unreachable-statement-compiler-error) – Smit Mar 29 '13 at 16:09

2 Answers2

2

You are getting an unreachable statement because of the continue; line.

presumably this code is inside of a loop, where continue actually has meaning.

The meaning of continue is answered Here, so I will not explain it futher.

When your code hits the continue it will not execute the following line:
InetAddress inetAddress = (InetAddress)localIterator2.next();

To fix this error, remove the continue; or the code after it.

Community
  • 1
  • 1
Colin D
  • 5,641
  • 1
  • 23
  • 35
1

Added line numbers for explanation...

localIterator2 = Collections.list(inetAddresses).iterator(); 
continue; ////any line after this never reach as the continue prevents it .
InetAddress inetAddress = (InetAddress)localIterator2.next(); 
Jayan
  • 18,003
  • 15
  • 89
  • 143