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. how does struts work in netbeans 6.9.1?what are th
View Tutorial          By: gunavathi at 2014-05-14 08:00:56

2. Hi... very nice tute... Thanks..
I am worki

View Tutorial          By: anuj at 2013-03-15 06:12:46

3. i have clear that notify and wait
but where

View Tutorial          By: pp at 2009-06-29 06:12:13

4. Handling several submissions can be a lot simple t
View Tutorial          By: Blaze Blankenship at 2012-12-05 13:04:12

5. very good helped me a lot
View Tutorial          By: Swaran at 2009-12-30 09:51:36

6. This example has helped me a lot.! kudos to the wr
View Tutorial          By: Disha Sareen at 2014-12-24 09:30:12

7. can I ask question? how to make a complete program
View Tutorial          By: manuel at 2012-08-13 10:06:24

8. I need to know the parameters that we need to pass
View Tutorial          By: puru at 2008-09-08 00:33:46

9. can you help me do this? - write a program that wi
View Tutorial          By: rence at 2011-08-16 13:33:14

10. i want some explanation about struts form field va
View Tutorial          By: ramizah at 2007-10-03 23:40:11