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. very good explanation... thnx...
View Tutorial          By: gobu at 2009-04-05 23:43:19

2. enter no of line: 5 not fix value
out put i

View Tutorial          By: mark at 2013-01-31 14:30:00

3. Hi Shruti, If you have better samples then feel fr
View Tutorial          By: jagan at 2010-03-03 19:42:46

4. nice example for understanding abstract class,,,bu
View Tutorial          By: Aavez Sk at 2012-01-17 09:44:36

5. You only need 1 main method per application, not 1
View Tutorial          By: Michael at 2011-09-02 02:37:51

6. Can any one tell me whether to add any external ja
View Tutorial          By: Abhi at 2010-02-23 05:25:29

7. really helpul........
pls mail me some more

View Tutorial          By: senthil at 2013-08-19 17:53:02

8. Thanks a lot. It was very helpful
View Tutorial          By: Faith Justin at 2008-12-07 06:52:29

9. introduction is very clear i get wat answer i want
View Tutorial          By: kalyan at 2013-07-02 09:23:40

10. Article from Java Complete Reference
View Tutorial          By: venkatesh at 2013-06-04 01:29:02