Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Does Java have buffer overflows? If yes can you give me scenarios?
I'm making my own custom server software for a game in Java (the game and original server software were written with Java). There isn't any protocol documentation available, so I am having to read the packets with Wireshark. While a client is connecting the server sends it the level file in Gzip format. At about 94 packets into sending the level, my server crashes the client with an ArrayIndex...
Its great when you can return a null/empty object in most cases to avoid nulls, but what about Collection like objects? In Java, Map returns null if key in get(key) is not found in the map. The best way I can think of to avoid nulls in this situation is to return an Entry<T> object, which is either the EmptyEntry<T>, or contains the value T. Sure we avoid the null, but now you ca...
What does this error mean? and how do I get rid of it? public class ARRAY { public static void main(String[] args){ String[] name = {"tom", "dick", "harry"}; for(int i = 0; i<=name.length; i++) { System.out.print(name[i] +'\n'); } } }
Why is this code correct: try { } catch(ArrayOutOfBoundsException e) { } and this wrong: try { } catch(IOException e) { } This code is wrong because in the try-body never an IOException is thrown, but in the first body there is also never throw a ArrayOutOfBoundsException. And the first code-piece is correct. Why?? Can I make my own exceptions also like IOException (Must be thrown bef...
Hey guys, with a lot of help from you i was managed to write this nice code (I'm new in it, so kind of exciting.. :) ) And still I have not understand how can I input this code. first of all, I get an this error in the console line (I'm using Eclipse): Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at NumberConverter.main(NumberConverter.java:5). What does that mea...
This is in an application I am using called Mirth, but it appears to be coming from inside an Apache Commons library from a method that checks if something is indeed Base64 encoded or not. All of the docs say the only return is true or false, so how am I getting -61? -61 org.apache.commons.codec.binary.Base64.isBase64(Base64.java:137) org.apache.commons.codec.binary.Base64.discardNonBase64(Ba...
why i cant compile this code?.. it has error on this code.. when i compile : cannot find symbol.method add. import java.util.*; public class ArrayList { // instance variables - replace the example below with your own public void processinput (String s) { int[] a = {34, 25, 16, 98, 77, 101, 24}; ArrayList b = new ArrayList(); for(int i = 0; i < a.length...
i need some help and guidance in displaying the splitted Strings in order. let say, i have username, password, nonceInString. i had successfully encrypted and decrypted those. then i split the decrypted data. it was done, too. i want to display the decrypted data in order. something like this. userneme: sebastian password: harrypotter nonce value: sdgvay1saq3qsd5vc6dger9wqktue2tz* i...
public class ArrayList { // instance variables - replace the example below with your own public void processinput (String s) { int[] a = {34, 25, 16, 98, 77, 101, 24}; ArrayList b = new ArrayList(); for(int i = 0; i < a.length; i++) { int d = a[i]; if(d%2 > 0) { b.add(new Integer(d)); } } ...
Why is this not catching Array out of bound ? try { double numValue = Double.parseDouble(value); table.get(row).set(colmn, numValue); } catch (NumberFormatException e ) { System.out.println("Sorry you can't store a word in a column that contains only numbers."); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Sorry ei...
Unless I'm mistaken, it is legal to have an array in Java indexed by character values, since these are equivalent to 8-bit numbers. However, the following code generates error messages for me: int[][] myArray = new int[256][256]; myArray['%']['^'] = 25; Is there a way to make this work? edit: Wow, I really didn't do a good job of copying over the code.
Why does ArrayIndexOutOfBoundsException occur and how to avoid it in Android?
It seems like in reality these should be almost identical. You are referencing or sticking data where it shouldn't go.
OK so I am getting an ArrayIndexOutofBoundsException. I don't know why. Here's my code: /** Tile Generator Programmer: Dan J. Thanks to: g00se, pbl. Started May 23, 2010 **/ import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class tileGen extends Applet implements KeyListener { Image[] tiles; // tile arrays Image player; // player image int x, y, px...
 /*
  * Copyright 1994-1997 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Sun designates this
  * particular file as subject to the "Classpath" exception as provided
  * by Sun in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 */
package java.lang;

Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.

Author(s):
unascribed
Since:
JDK1.0
public
Constructs an ArrayIndexOutOfBoundsException with no detail message.
        super();
    }

    
Constructs a new ArrayIndexOutOfBoundsException class with an argument indicating the illegal index.

Parameters:
index the illegal index.
    public ArrayIndexOutOfBoundsException(int index) {
        super("Array index out of range: " + index);
    }

    
Constructs an ArrayIndexOutOfBoundsException class with the specified detail message.

Parameters:
s the detail message.
        super(s);
    }
New to GrepCode? Check out our FAQ X