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



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 am getting this error how to erase it please tel
View Tutorial          By: laxmibvsn at 2012-10-16 15:45:05

2. How to delete file button
View Tutorial          By: Chinzoo at 2013-04-13 13:30:18

3. Thanks for a nice article !!!
View Tutorial          By: Piyush Sharma at 2011-12-15 12:24:06

4. Hi,first of all thats for this code developer, its
View Tutorial          By: Kathir at 2008-02-08 06:16:51

5. What a wonderful site for beginners? Now I can pra
View Tutorial          By: Kafedha Rwezaula at 2010-06-03 04:39:59

6. this is really helpful example for Learning RMS in
View Tutorial          By: Ahmed Nawaz Mari at 2011-06-30 05:29:18

7. ..how if the input is THE DOG BARKS then the outpu
View Tutorial          By: dharel at 2011-01-28 02:53:19

8. can we print only second by using the date functio
View Tutorial          By: mukesh kumar at 2011-07-27 02:31:02

9. Hi Friends.... This code is working correctly with
View Tutorial          By: kasi at 2009-11-25 23:52:56

10. Where should I call the action /editRegistration?
View Tutorial          By: Andrei at 2013-03-08 12:21:07