Problems with IndexOutOfBoundsException

Status
Nicht offen für weitere Antworten.
P

polishjazz

Gast
A help in German language can be very helpful too! :)

I'm using a standard applet from samples delivered with the Java Developer Kit, called GraphLayout... It's an easy-to-use network building tool (all you have to do is add values to 'edges' parameter in the HTML code). But I've noticed that if I exceed a certain number of connections, the applet doesn't work. The status bar of the browser says something like that:

Code:
exception java.lang.Array.IndexOutOfBounds.Exception

What could be the problem? How to solve it?

You can take a look at the page www.postdigital.nl/javaproblem to see what I mean or just download the .zip file with all java/html files in it.

I would be very grateful for your help!

edit deathbyaclown: changed to an adequate title
 

nollario

Bekanntes Mitglied
i did not read your sources, but nevertheless: an arrayindexoutofboundsexception usually occurs if you are accessing an element of an array, which does not exist.

e.g.:

Code:
int[] numbers = new int[5];

...

int sum = 5 + numbers[10];
 

Isaac

Bekanntes Mitglied
Code:
    int findNode(String lbl) {
	for (int i = 0 ; i < nnodes ; i++) {
	    if (nodes[i].lbl.equals(lbl)) {
		return i;
	    }
	}
	return addNode(lbl);
    }

Thats the problem. I dont know how or if you modified the string you transfer to the applet. But this little method checks if a node is already present and if not, it creates a new node (Node = String in the paramter, like "bath" for example). But if you add more then 100 different Nodes to the Array

Code:
Node nodes[] = new Node[100];

You applet crashes with a ArrayIndexOutOfBoundsException because it tries to create a nodes[101];
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
G Eclipse: In Problems View schreiben? Java Basics - Anfänger-Themen 10
R Problems with PrintOutputStream Java Basics - Anfänger-Themen 7
D Unerklärliche IndexOutOfBoundsException Java Basics - Anfänger-Themen 5
S IndexOutOfBoundsException beim hinzufügen eines Elements zu einer Liste Java Basics - Anfänger-Themen 11
V Compiler-Fehler Warum eine IndexOutOfBoundsException? Java Basics - Anfänger-Themen 3
K Dateien lesen | IndexOutOfBoundsException Java Basics - Anfänger-Themen 2
O java.lang.IndexOutOfBoundsException JTable autoSort Java Basics - Anfänger-Themen 5
S Methoden Bei Liste als Rückgabewert: IndexOutOfBoundsException Java Basics - Anfänger-Themen 1
H java.lang.IndexOutOfBoundsException bei verschachtelter ArrayList Java Basics - Anfänger-Themen 9
P Problem mit IndexOutOfBoundsException Java Basics - Anfänger-Themen 11
K Compiler-Fehler IndexOutOfBoundsException bei ArrayList Java Basics - Anfänger-Themen 2
R IndexOutOfBoundsException bei ArrayList Java Basics - Anfänger-Themen 2
K Fehlermeldung: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 Java Basics - Anfänger-Themen 4
N IndexOutOfBoundsException: Source does not fit in dest beim Kopieren von ArrayList in Vector Java Basics - Anfänger-Themen 4
M ArrayList, String Array und IndexOutOfBoundsException Java Basics - Anfänger-Themen 2
S IndexOutofBoundsException bei linkedlist Java Basics - Anfänger-Themen 5
M java.lang.IndexOutOfBoundsException weiß nicht warum Java Basics - Anfänger-Themen 8
R IndexOutOfBoundsException bei Listen Java Basics - Anfänger-Themen 7
Student Transponieren von 2 Arrays - IndexOutOfBoundsException Java Basics - Anfänger-Themen 15
G Wo ist mein Fehler (IndexOutOfBoundsException)? Java Basics - Anfänger-Themen 3

Ähnliche Java Themen

Neue Themen


Oben