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. Error loading SolarisSerial: java.lang.Unsatisfied
View Tutorial          By: amit doshi at 2009-04-06 02:00:28

2. nice intelligent work
View Tutorial          By: santosh at 2010-11-28 01:18:50

3. Thank you, very useful example!
View Tutorial          By: Hui Chun Wai at 2013-03-24 15:07:53

4. Hi,
I am getting this exception..My modem i

View Tutorial          By: divya at 2008-04-27 04:12:19

5. iam getting intrest to watch this site
View Tutorial          By: monika at 2013-02-15 15:48:57

6. Great stuff - helped me setting up the company SQL
View Tutorial          By: JW at 2011-07-11 12:09:19

7. It takes me time to understand the process of the
View Tutorial          By: Abdullah Ibrahim at 2012-04-11 00:38:23

8. Thanks for this tutorial . This provides me lots
View Tutorial          By: Pranit at 2011-07-25 09:12:29

9. thaks sir for giving information about adding int
View Tutorial          By: vijay kumar at 2012-10-10 04:59:05

10. Thanks this tutorial helped me :)
View Tutorial          By: Anuja at 2012-07-17 06:59:39