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. Dear Friends, I get the following exception...

View Tutorial          By: NT.Jay at 2011-10-06 05:33:09

2. I am not able to open the rar file, can you please
View Tutorial          By: Chandra at 2008-08-07 10:35:59

3. Thanks for this great tutorial... was looking for
View Tutorial          By: Shashi at 2012-09-20 11:35:08

4. Very nice
View Tutorial          By: sharath at 2012-07-17 11:31:20

5. its not solve my problem.i.e
the concept is

View Tutorial          By: murli at 2010-10-02 23:23:11

6. good info to create package
View Tutorial          By: Nirdesh at 2012-10-01 03:45:02

7. hi sir
im a student of aitm im doing speec

View Tutorial          By: sinan ahmed at 2015-02-09 05:45:49

8. I think this code is just simple enough to be foll
View Tutorial          By: WAQ at 2010-11-24 10:41:58

9. hi,

i am trying to run this SMS jav

View Tutorial          By: Raghavendra at 2010-12-29 08:27:02

10. "If you enter zero, the assert() macro forces
View Tutorial          By: czx at 2010-09-17 07:23:20