Free Java Programs
WAP to sort a array in Java
import java.io.*;
class sort
{
public static void main(String args[])throws IOException
{
int a[]=new int[5];
int i,j;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the value");
for(i=0;i<5;i++) str="br.readLine();" i="0;i<5;i++)" j="i+1;j<5;j++)">a[j])
{
int temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.println("the sorted array is:");
for(i=0;i<5;i++)
{
System.out.println(a[i]);
} }
}
WAP to sort a array in Java
import java.io.*;
class sort
{
public static void main(String args[])throws IOException
{
int a[]=new int[5];
int i,j;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the value");
for(i=0;i<5;i++) str="br.readLine();" i="0;i<5;i++)" j="i+1;j<5;j++)">a[j])
{
int temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.println("the sorted array is:");
for(i=0;i<5;i++)
{
System.out.println(a[i]);
} }
}