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. its really helpfull to understand.
View Tutorial          By: rakhi at 2010-08-08 12:45:05

2. new Thread(this , "Demo thread") mean
View Tutorial          By: shalini at 2011-12-06 07:29:20

3. you example does not run it errors can you pls fix
View Tutorial          By: dionesia at 2009-08-24 05:27:37

4. nice work.......
View Tutorial          By: sukirti at 2011-05-06 16:30:19

5. it would be very helpful if you demonstrated how t
View Tutorial          By: newcoder at 2011-10-24 17:40:25

6. Your explanation is good but, it will be better i
View Tutorial          By: Jabaraj at 2010-03-22 06:02:33

7. @bibiki, you are right for simpler conditions what
View Tutorial          By: Marcin at 2012-04-05 02:34:13

8. hiii
i m doing my final year project on sms

View Tutorial          By: jiya at 2010-10-21 07:58:24

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

10. I need a payroll system program in c++ using class
View Tutorial          By: tesfay at 2012-01-19 12:08:55