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. please provide Example instanceof With Collection
View Tutorial          By: siddardha at 2010-08-18 00:30:38

2. Please don't use DataInputStream to read text. Unf
View Tutorial          By: Peter Lawrey at 2013-01-30 23:46:47

3. sir i want to knw abt all simple java programs pls
View Tutorial          By: sakthi at 2011-08-29 14:06:10

4. Hello, I have a problem
I cant understand s

View Tutorial          By: henry at 2012-01-10 07:53:05

5. Thank you very much sir.
One can simply exe

View Tutorial          By: rudhin at 2013-05-10 12:32:57

6. Error loading SolarisSerial: java.lang.Unsatisfied
View Tutorial          By: Sony at 2008-09-10 01:28:52

7. Hi Dear All

How to do strike-out in

View Tutorial          By: Sandeep Mehta at 2012-11-21 06:54:06

8. Hi i 've used this SMSClient.java in my simple pro
View Tutorial          By: Prakah at 2011-12-22 17:10:48

9. If one can't use English grammar correctly and wit
View Tutorial          By: Java Man at 2011-12-09 06:04:14

10. if u need simple definition then that are

View Tutorial          By: rizvaankhan at 2011-10-10 13:13:36