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 your explanation is absolutely correct but I am
View Tutorial          By: Anil R. Chinchawade at 2010-07-28 02:02:01

2. very nice..thank you so much.all the concepts are
View Tutorial          By: Priya at 2013-01-01 07:39:04

3. Real Life example of using Volatile
*******

View Tutorial          By: Mayank at 2011-01-25 15:44:21

4. nice
View Tutorial          By: knraju at 2012-04-13 13:49:57

5. This is really helpful.
View Tutorial          By: srikanth at 2009-03-11 08:04:04

6. org.apache.jasper.JasperException: An exception oc
View Tutorial          By: manikanta at 2015-02-02 05:39:09

7. this is no doubt a simple program for the learner
View Tutorial          By: shweta at 2008-07-12 01:18:59

8. Good explanation, Thanks.
View Tutorial          By: bram at 2011-05-06 03:37:54

9. Can anybody send me the java full code for sending
View Tutorial          By: David at 2010-08-22 22:57:38

10. good tutorial for beginners..........
View Tutorial          By: Madarapu naveen at 2011-06-18 11:19:50