Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 823925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:01:14+00:00 2026-05-15T03:01:14+00:00

OK so my code is here: http://www.so.pastebin.com/m7V8rQ2n What I want to know… let’s say

  • 0

OK so my code is here: http://www.so.pastebin.com/m7V8rQ2n

What I want to know… let’s say I have an image which I can redraw on tiles… is there a way to check for future tiles so I DON’T go out of bounds of my already defined tile map?

Like if I were at the edge of a map… it would NOT let me go past it?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:01:15+00:00Added an answer on May 15, 2026 at 3:01 am

    Generally speaking, preventing ArrayIndexOutOfBoundsException can be done by simply making sure that the index is within the bound.

    JLS 10.4 Array Access

    All arrays are 0-origin. An array with length n can be indexed by the integers 0 to n-1.

    Thus, a simple check like this is quite typical:

    if (i >= 0 && i < arr.length) {
        System.out.println(arr[i]);
    }
    

    Barring nasty things like arr getting reassigned between the check and the access, the above code will NEVER throw ArrayIndexOutOfBoundsException.


    2D array "boards"

    Often, you can be a lot more specific, e.g. when you have rectangular "boards" stored in a two-dimensional array (or rather, array of arrays in Java).

    final int M = 10;  // height, i.e. number of rows
    final int N = 8;   // width, i.e. number of columns
    final int[][] board = new int[M][N];
    

    Then you can have a method like the following:

    boolean isInBound(int r, int c) {
        return (r >= 0) && (r < M) && (c >= 0) && (c < N);
    }
    

    The bound check is both easier to read and to write, since we know that we have an MxN board. If isInBound(r, c), then board[r][c] will NEVER throw ArrayIndexOutOfBoundsException.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Download source code here: http://www.eyeClaxton.com/download/delphi/ColorSwap.zip Yes, I want to convert something mostly blue to
I found this code from here: http://www.cssportal.com/form-elements/text-box.htm But the problem is you can still
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does
Here is the code: <div><a><img src= http://www.seeklogo.com/images/R/Random_House_Bertelsmann-logo-B80776D5CA-seeklogo.com.gif/>Test</a>​​​​​​​​​<div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ Here is the fiddle: http://jsfiddle.net/zjfw2/ Thanks.
Here is my code. <div> <object> <param name="movie" value="http://www.youtube.com/v/Cbspv1ZKR8o?version=3&amp;hl=en_US" /> <param name="allowFullScreen" value="true" />
Using the code here: http://www.w3schools.com/php/php_xml_parser_expat.asp How would you get the attributes using the switch
I modified the code here (http://www.w3schools.com/PHP/php_ajax_database.asp) to update and display my database after an
In source code here http://www.daftlogic.com/sandbox-javascript-slider-control.htm There is these instructions: // safely hook document/window events
Sorry just found this code here - http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html and the mutex was explained with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.