Comment on Tutorial - Bubble Sort in Java By SPlutard



Comment Added by : Siva

Comment Added at : 2012-04-17 05:19:28

Comment on Tutorial : Bubble Sort in Java By SPlutard
I 've tried the program for Bubble Sort. This progarm is compling but Not running. And its Showing a Runtime error As"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at Bubble.BubbleSort(Bubble.java:15)
at Bubble.main(Bubble.java:5).
Can Anyone help me to solve that
The Prigram is as follws........


public class Bubble{
public static void main(String args[]){
int Array[]={4,2,5,20,3};
int i;
BubbleSort(Array,Array.length);
for(i=0;i<Array.length;i++){
System.out.println("Array before Sorting:"+Array[i]);
}
}

public static void BubbleSort(int[] Array,int length){
int index,counter,temp;
for(counter=0;counter<=length-1;length++){
for(index=0;index<length-1-counter;index++){
if(Array[index]>Array[index+1]){
temp=Array[index];
Array[index]=Array[index+1];
Array[index+1]=temp;
}
}
}
}
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Hi I need code examples J2ME for chating aplicatio
View Tutorial          By: agus at 2010-04-03 04:16:11

2. HI,

can any one tell me small but s

View Tutorial          By: Amujuri Vivek at 2013-01-08 02:48:50

3. I can't compile the source with Dev-C++ 4.9.9.2, h
View Tutorial          By: ToKha at 2013-11-19 01:32:34

4. it s good ,understanding clearly and with out conf
View Tutorial          By: vasudeva kumar at 2012-01-06 14:04:30

5. The example is awesome i found it most useful amon
View Tutorial          By: sabir pasha at 2009-01-20 05:11:34

6. Thanks.It is very helpful
View Tutorial          By: JENI at 2013-03-23 11:01:58

7. I have tried that but still getting the same error
View Tutorial          By: pra at 2008-04-14 21:55:44

8. in my case the culprit is xdebuger dll version 2.0
View Tutorial          By: putra at 2009-12-18 00:39:42

9. To "need help":

String s

View Tutorial          By: Mike at 2010-10-14 20:09:31

10. It is very simple and understandable tutorial, the
View Tutorial          By: Syed Turab at 2010-03-09 07:27:15