How to perform quicksort in Java?

public class QuickSort {
public static void main(String[] args) {
int i;
int[] arr={90,23,101,45,65,23,67,89,34,23};
quickSort(arr, 0, 9);
System.out.println("\n The sorted array is: \n");
for(i=0;i<10;i++)
System.out.println(arr[i]);
}
public static int partition(int a[], int beg, int end)
{

int left, right, temp, loc, flag;
loc = left = beg;
right = end;
flag = 0;
while(flag != 1)
{
while((a[loc] <= a[right]) && (loc!=right))
right--;
if(loc==right)
flag =1;
elseif(a[loc]>a[right])
{
temp = a[loc];
a[loc] = a[right];
a[right] = temp;
loc = right;
}
if(flag!=1)
{
while((a[loc] >= a[left]) && (loc!=left))
left++;
if(loc==left)
flag =1;
elseif(a[loc] <a[left])
{
temp = a[loc];
a[loc] = a[left];
a[left] = temp;
loc = left;
}
}
}
returnloc;
}
static void quickSort(int a[], int beg, int end)
{

int loc;
if(beg<end)
{
loc = partition(a, beg, end);
quickSort(a, beg, loc-1);
quickSort(a, loc+1, end);
}
}
}

Output:

The sorted array is:
23
23
23
34
45
65
67
89
90
101
Author's Other questions
 Write a program to calculate the difference between the sum of the odd level and even level nodes of a Binary Tree Write a program in Java to find the maximum and minimum value node from a circular linked list. Write a program in Java to create a doubly linked list containing n nodes How to perform merge sort in Java? How to perform Linear Search in Java? How to perform Selection Sort in Java? How to perform Binary Search in Java? How to perform Bubble Sort in Java? Can RMI and CORBA based applications interact? What is JRMP? What is the use of HTTP-tunneling in RMI? What are the steps involved to write RMI based programs? What is the purpose of stub and skeleton? What do you understand by the bean persistent property? What is the purpose of using the Java bean? What is a JavaBean? How will you load a specific locale? What is Locale? Can you write a Java class that could be used both as an applet as well as an application? What is an applet?