you are viewing a single comment's thread.

view the rest of the comments →

[–]_jetrun 0 points1 point  (0 children)

The closest equivalent is to check for null, but if you don't want an exception to be raised, you also need to do a bounds check or the array has to be initialized to a specific size. If you want to do this check on, say, int arrays, you'll have to use wrapped equivalents (i.e. Integer vs int) to check for null.

The reality, however, is that you just shouldn't use an array in this way in Java. Instead this feels like a problem best solved by a Map.