Results 1 to 2 of 2
  1. #1
    Dude10 is offline Member
    Join Date
    Nov 2014
    Posts
    6
    Rep Power
    0

    Default Can I compare to an index out of bounds?

    I have a 2-D character array and I was wondering if I can compare a given index to an out of bounds index and what would I have to write? For instance

    if(array[0 - 1][0 - 1] == 'indexoutofbounds'){ **// I know that 'indexoutofbounds' is probably not the right wording**
    stuff happens
    }

    If I can do this what would I actually have to write in where it says 'indexoutofbound' ?

    I will be using this for many indexes so it wont always be [0 - 1][0 - 1] it could be [4 - 1][3 - 1] in which case it wouldn't be out of bounds and wouldn't move onto "stuff happens"

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Can I compare to an index out of bounds?

    compare a given index to an out of bounds index
    Any index past the array's length-1 is out of bounds.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. String Index Out of Bounds Exception
    By phyzix5761 in forum New To Java
    Replies: 4
    Last Post: 11-09-2012, 09:09 PM
  2. array index out of bounds
    By searcher in forum New To Java
    Replies: 3
    Last Post: 01-21-2012, 02:27 PM
  3. having an array index out of bounds problem
    By samanyu in forum New To Java
    Replies: 18
    Last Post: 06-03-2011, 08:12 AM
  4. Index out of bounds Numeric analyzer.
    By Sean_J in forum New To Java
    Replies: 3
    Last Post: 03-17-2010, 03:06 PM
  5. Array Index out of bounds
    By leapinlizard in forum New To Java
    Replies: 5
    Last Post: 04-29-2009, 05:11 AM

Tags for this Thread

Posting Permissions

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