Java Tutorial

 
 
 
 
import java.io.*;

class sort
{
      String str;
      int size,sortArr[];

      public void getdata()
      {
             System.out.print(\"Enter how many data you want to enter : \");
             System.out.flush();
             try{
                 BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
                 str=obj.readLine();
                 size=Integer.parseInt(str);
                 sortArr=new int[size];
                 for(int i=0;i<size;i++)
                   {
                       System.out.print(\"Enter element at \"+(i+1)+\"th position  :  \");
                       System.out.flush();
                       str=obj.readLine();
                       sortArr[i]=Integer.parseInt(str);
                   }
                }
            catch(Exception e)  {}
      }

      public void  LinSort()
      {
            System.out.println(\"=====LINEAR SORT=====\\n\");
            getdata();
                for(int i=0;i<size;i++)
                    {
                  for(int j=i+1;j<size;j++)
                      {
                         if(sortArr[i] > sortArr[j])
                          {
                               int temp=sortArr[i];
                               sortArr[i]=sortArr[j];
                               sortArr[j]=temp;
                          }
                     }
                  }
            display();
        }    

    public void display()
    {
         System.out.println(\"\\nAfter Sorting\");
         for(int i=0;i<size;i++)
              System.out.println(sortArr[i]);
    }
}


class LinSort 
{
    public static void main(String args[]) 
    {
          sort ob1=new sort();
          ob1.LinSort();
    }
}

    Related Post:
  1. RMI servlet program to display message

  2. File handling program to count number of characters in a file

  3. Program to copy the elements of an array into another array in reverse order and print them

  4. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

  5. Program that reads and writes random access file

  6. Program that maintains employee database of an education system

  7. Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side

  8. Program to declare, initialize and print a 2D array of integers

  9. Program to show an example of using constructors in a class to initialize its data members

  10. Program to show the use of Logical or Boolean Negation i.e. NOT (!)

  11. An applet program to draw circle in center of the canvas

  12. Program to show the use of If Statement

  13. File handling program to copy bytes from one file to another

  14. Program for calculating area of a circle on server side,when a client sends request along with given radius and then displaying result on client side

  15. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  16. Program to find a factorial of a given number

  17. Program to generate SQUARE ROOT table

  18. Program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7

  19. corba program of client and a DNS server where given a URL the server sends back an IP address

  20. Corba program of Count Client Applet, IDL,Server, Client

 
 
Didn't find what you were looking for? Find more on An applet program of linear sort