unreachable statement

Posted on Febrero 22, 2008. Filed under: Java | Tags: |

Este error se produce porque parte de nuestro código nunca se va a ejecutar, es inalcanzable (unreachable)

Generalmente sucede por colocar alguna sentencia despues de un <code>return</code>

Por ejemplo:


   public boolean verificar(){
      if(...){
         ...
         return false;
      } else{
         ...
         return true;

         System.Out.printf("Esta linea es inalcanzable");
      }
   }

La forma de solucionarlo es o borrando todo el código inalcanzable o reubicándolo  de forma correcta:


   public boolean verificar(){
      if(...){
         ...
         return false;
      } else{
         ...

         System.Out.printf("Ahora si es alcanzable");

         return true;
      }
   }

Saludos

Make a Comment

Make A Comment: ( 1 so far )

blockquote and a tags work here.

One Response to “unreachable statement”

RSS Feed for Le Funes Comments RSS Feed

Me ha servido de ayuda. Muchas gracias :D. Ahora ya desaparecen las alertas del easyeclipse :D.

Si te gusta la música ahí tienes un regalo de agradecimiento:
http://www.thewish.es
http://www.myspace.com/thewishrules

j.thewish
Junio 3, 2008

Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...