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. EJB's can be deployed on multiple servers and when
View Tutorial          By: Tomek at 2011-09-12 12:29:07

2. very usefull article............ thanks to the aut
View Tutorial          By: runa at 2010-10-16 08:43:38

3. u hav done Nice job..
View Tutorial          By: Rakesh at 2012-10-01 16:00:14

4. everything is easy to learn from your website.I un
View Tutorial          By: sumitra barua at 2012-05-30 03:13:10

5. My code runs smoothly. I have taken some steps for
View Tutorial          By: Amit Shrivastava at 2015-01-25 13:48:46

6. Thanks for a great post. Solved a problem for me i
View Tutorial          By: Mark at 2013-01-08 07:00:47

7. good
View Tutorial          By: epuri at 2008-09-09 01:05:56

8. Very good example .. i ve written this program . P
View Tutorial          By: gomz at 2011-09-26 12:33:54

9. Great Thanks
View Tutorial          By: anawaz at 2012-10-05 10:28:20

10. wen i run i get dis error

jdbc:mysq

View Tutorial          By: sandeep at 2009-11-24 08:24:20