Hi,

Im new to java

im trying to study sorting methods specifically bubble sorting

i found this code online but couldn't understand what it means. can someone kindly comment the codes so I can uderstand it well.

TIA

here's the code

public static void sort( int a[], int n )   		// Bubble Sorting //
	  {
	  int i, j,t=0;
	  	for(i = 0; i < n; i++)
	 	 {
	  		for(j = 1; j < (n-i); j++)
	  			{
	  			if(a[j-1] > a[j])
	  			{
				  t = a[j-1];
				  a[j-1]=a[j];
				  a[j]=t;
	  			}
	  }
	  }
	  }

That's not how these forums work.
Ask for help after you've done some work yourself.
Two minutes with Google will give you all the information you could possibly want on bubble sorts in Java.

Sorry man, im just new here. I already got it btw. sorry for the bother

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.