Results 1 to 3 of 3
  1. #1
    jdodle is offline Member
    Join Date
    Oct 2013
    Rep Power

    Default Unreachable Code


    I have a private global integer array that is supposed to hold a value representing the number of cards in a deck (each index represents a different deck). I also have a 2 dimensional array for my decks (each row is a deck and each column is a card), and each card is also an object. so when I add a card to one of my decks, i need to also increase the card count in the global array by one. so when I do this (i.e. array[5] += 1;) i get an error saying that array is unreachable. how can this be fixed.

    P.S. I know this is a general explanation, but I am also looking for a general answer, something like an explanation of unreachable code and common steps to resolve the issue. This being said, if more information is needed say so and I will do my best to provide it.


  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Rep Power

    Default Re: Unreachable Code

    You probably have a return statement somewhere before that line. Posting your code would help, however.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Rep Power

    Default Re: Unreachable Code

    return statement, or a throw statement perhaps. Probably not though, exception handling will probably be a step too far for someone who hasn't learned to deal with unreachable statements yet :)

    Java Code:
    return 10;
    System.out.println("You can't reach me!");  // unreachable code, you can't ever get here because of the return statement
    Java Code:
    if(state == State.ERROR){
      throw new AppIsInErrorStateException("Blammo!");
      System.out.println("You can't reach me!");  // unreachable code, you can't ever get here because of the exception being thrown
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. unreachable statement.
    By gbonecapone in forum New To Java
    Replies: 10
    Last Post: 05-22-2013, 02:59 PM
  2. Unreachable statement. please take a look.
    By gbonecapone in forum Advanced Java
    Replies: 1
    Last Post: 05-22-2013, 01:52 PM
  3. Unreachable statement???
    By dangolf in forum New To Java
    Replies: 5
    Last Post: 02-12-2013, 11:55 AM
  4. Unreachable statement
    By lala in forum New To Java
    Replies: 3
    Last Post: 11-25-2010, 04:32 PM
  5. Unreachable statement Pig Dice Game
    By noturn10 in forum New To Java
    Replies: 2
    Last Post: 11-22-2009, 01:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts