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



Ask a Question

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. i have a problem .
i am getting an error ca

View Tutorial          By: chaitra at 2011-11-16 07:28:29

2. Hi All..
Wen i'm running the code..the foll

View Tutorial          By: mounika at 2008-04-26 14:27:30

3. may i have one more example
View Tutorial          By: bujii at 2015-05-08 03:04:40

4. Hello Friends ,

s1 == s2 will alway

View Tutorial          By: Gunjan at 2010-09-08 19:24:24

5. Please send the complete code.. thanks!
View Tutorial          By: Roger22 at 2010-03-11 00:41:07

6. Caught java.lang.ClassNotFoundException: com.sun.c
View Tutorial          By: A.Balaji at 2010-09-13 00:15:48

7. I want to use concept of overriding and i want to
View Tutorial          By: Aniket at 2013-06-20 10:23:10

8. Plz help me......its urgent
i need a code

View Tutorial          By: Nisha at 2010-03-22 00:38:42

9. I can not understand left shift operater ,i am a f
View Tutorial          By: umar at 2012-01-31 12:28:11

10. it giving me error in following statment (using wi
View Tutorial          By: prathamesh at 2007-03-16 05:57:20