Thứ Bảy, 30 tháng 8, 2014

An intoduction to AJAX technology.

Before we go deep into the technology lets have a refresh with traditional web-processing,Ajax web-processing

Traditional web-processing:
----------------------------------
With traditional web pages and applications, every time a user clicks on something, the browser sends a request to the server, and the server responds  with a whole new page.

 Now ,lets see the Ajax web-processing

Using Ajax, your pages and applications only ask the server for what they really need—just the parts of a page that need to change, and just the parts that the server has to provide.


now,lets write a simple Ajax program that gives current time and date of your machine.(In order to work with Ajax you need to have a basic knowledge on javascript,hrml,any one scripting language(php/jsp/asp...etc).

Html code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Ajax Data base</title>
<script type="text/javascript">
var x;
function demo()
{
    if(window.XMLHttpRequest)
        {
        x=new XMLHttpRequest();
        }
    else
        {
        x=new ActiveXObject("Microsoft.XMLHTTP");
        }
    x.onreadystatechange=function()
    {
        if(x.readyState==4 && x.status==200)
            {
            document.getElementById("dat").innerHTML=x.responseText;
            }
    }
    x.open("GET","database.jsp", true);
    x.send();
}
</script>

</head>
<body>
<center>
<h5>THis is a demo on database
</h5></center>
<button type="button" onclick="demo()">GetDate</button>

<div id="dat"></div>
</body>
</html>


This looks like new to every one,but it is simple to understand.

1.An AJAX code is written inside a javascript function.
2.In order to connect this page to the server we need a request object,you will get this by using var x=new XMLHttpRequest();  but the problem is ,this will work only for browsers like mozilla ,netscape,safari...etc [doesn't work with internet explorer].
3.to work with internet explorer we need an ActiveXobject as show in program.
4.Now we have an object of request so,if there is any changes occured(user clicks on something) send that changes by using request object.
5.finally we have to specify to which page of server request will go? we do this by send("GET","database.jsp",null) method.

 database,jsp 

<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%
out.print(new Date());
%>





output:


on clicking get data you will get(observe that your page will not loaded at this moment )



Thứ Sáu, 29 tháng 8, 2014

Checking weather two strings are anagrams or not? in c++

Hi Guys,

Anagrams: An anagram is a type of word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once
preconditions:
1.both strings must have same length
2.each character in string is unique(no character must be repeated).

For instance   string1="sir", string2="sri"   these two strings are anagrams.
Solution:
#include<iostream.h>
#include<string.h>
#include<conio.h>
int main()
{
clrscr();
char arr[]="sri";
char arr1[]="sir";
int i,j,c=0;
int len1=strlen(arr);
int len2=strlen(arr1);
if(len1!=len2)
cout<<"Both Strings are not an anagram";
for(i=0;i<len1;i++)
{
 for(j=0;j<len2;j++)
 {
    if(arr[i]==arr1[j])
    {
    c++;
    }
 }
}
if(c==len1 && c==len2)
cout<<"given strings are anagrams";
else
cout<<"given strings are not anagrams";
return 0;
}


output:
-----------------------------




Converting a String to int with out using parseInt() in java

Hi Guys ,welcome

         You might have performed converting a string to an int when you are reading data from standard inputstreams(because it treats input data as string format).

for example see the below snippet

Scanner sc=new Scanner(System.in);//sc is pointing to inputstream as in string format.
int data=sc.nextInt();

if you are readed data using BufferedReader,then code snippet will be like

InputStreamReader in=new InputStreamReader(System.in);
BufferedReader br new BufferedReader(in);
int data=Integer.parseInt(br.readLine());

Now our aim is to perform same convertion with out using above methods.

preconditions are :
1.check if number is positive or negitive (do this by using charAt() method).
2.if number is negitive return negitive number

logic:
         number="12345"; //is a string number
         if(number.chatAt(0)=='-')//it is a negitive number so return negitive number
         return =number;

Solution:

                package logics;

public class check {
    public static void main(String []args)
    {

        String data="12345";
        System.out.println("String data before converting to int "+data);
        int res=toInt(data);
        System.out.println("in integer format \t"+res);
       
    }
    public static int toInt(String data)
    {
        int index,start=1,len=data.length(),intdata=1;
        boolean isnegitive=false;
        if(data.charAt(0)=='-')
        {
            isnegitive=true;
        }
        while(start<len)
        {
            intdata*=10;
            intdata+=(data.charAt(start++)-'0');
           
        }
        if(isnegitive)
            intdata=-intdata;
        return intdata;
       

    }
}


output:

------------------------------------------
String data before converting to int 12345
in integer format     12345
 


Thứ Ba, 26 tháng 8, 2014

String Chain program in Java

Hi Guys ,Welcome

Am giving you an intresting program here called "String Chain" .Before that we need to know what is string chaining???well,
 it's a process of chaining Strings baced on some specific characters arrangement.

for example:

let we have strings like  "shashi","shankar","rock","kiran","tail".Here chaining is done if and only if

last character of first string is equal to the first character of next string in an array.

now apply chain rule for above strings it becomes:

shankar-->rock--->kiran-->null (here null means there is no further names to place in this chain).

I hope you would  understand the concept..................lets move to code.

solution:


package logics;
import java.util.*;

public class StringChain {
    public static void main(String []args)
    {
        String []data={"shashi","shankar","rock","kiran","tail"};
        int index=0;
        int length1=data.length;
        ArrayList<String>list=new ArrayList<String>();
        String []res=new String[20];
        for(int i=0;i<length1;i++)
        {
            int endlength=data[i].length()-1;
       
            char end=data[i].charAt(endlength);
       
            for(int j=i+1;j<length1;j++)
            {
   
                char start=data[j].charAt(0);

           
                if(end==start)
                {
                   
                    res[index++]=data[i];
                   
                    res[index++]=data[j];

                }
               
            }
           
        }
        for(String str:res)
        {
            if(list.contains(str))
            {
            }
            else
            {
                list.add(str);
            }
        }
        Iterator<String> ite=list.iterator();
        while(ite.hasNext())
        {
            System.out.print(ite.next()+"-->");
        }
    }

}


output:

===============================
shankar-->rock-->kiran-->null-->

A "C++"program to replaces emptyspaces with some character.

Hi Guys,Welcome

 Aim of this program is to replace an empty space by using a character.for example a string is given like

"shashi kumar",you have space between i and k ,now you need to fill this space with "%20".


Wrong Program:

Here am giving a code that actually doesn't work .But you can observe why that doesn't work in later Program.

#include<iostream.h>
#include<conio.h>
int main()
{
char array[]="shashi kumar";
clrscr();
int i;
for(i=0;array[i]!='\0';i++)
{
    if(array[i]==' ')
    {
    array[i]='%20';                          //line XX

    }
}
cout<<"printing data";
for(i=0;array[i]!='\0';i++)
{
cout<<array[i];
}

return 0;

}

output:
-------------------------


The reason for this is see code at line no xx.

Right Program;


void replace(char [],int);
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
char data[]="shashi kumar follow my totorials";
int length=0,i;
for(i=0;data[i]!='\0';i++)
{
length=length+1;
}
replace(data,length);
return 0;
}
void replace(char a[],int l)
{
    int i,j;
    char rep[100];
    for(i=0,j=0;i<l;i++)
    {
        if(a[i]==' ')
        {
         rep[j++]='%';
         rep[j++ ]='2';
         rep[j++]='0';
        }
        else
        {
        rep[j++]=a[i];
        }


    }
    rep[j]='\0';
    //printing string now
    for(i=0;rep[i]!='\0';i++)
    cout<<rep[i];

}


output:

--------------------------------




Second version of finding common letters in "AMITABH BHACHAN" and "RAJINIKANTH"

Hi Guys,,

you know why am focusing on this java program especially??????

-->the reason is if you ever applied an internship through twenty20.com  ,every company asking code for this program[I don't know why they are giving same program for all recruitment ].

In my previous version am developed a solution using stringbuffer classes it becomes very lengthy and bit of confusing,so here am giving a simple solution .follow this



solution:
==============
package logics;
import java.util.*;
public class amitabhRajini {
    public static void main(String[] args)
    {
        String name1="AMITABH BHACHAN";
        String name2="RAJINIKANTH";
        char []array1=name1.toCharArray();
        char []array2=name2.toCharArray();
        Set<Character> s=new HashSet<Character>();
        Set<Character> common=new HashSet<Character>();
        for(char che:array1)
        {
            s.add(che);
          
        }
        for(char che1:array2)
        {
            if(s.contains(che1))
            {
                common.add(che1);
            }
        }
        System.out.print(common);
      
      
    }
}


output :

---------------------------------
[T, A, N, H, I]

Concatinating Two Strings without Using concat() method of java string class

Hi Guys,


It's very simple

step1:convert your string to a character array

step2:Create an ArrayList add each string to this list and finally return list.

Program:

package logics;

import java.util.ArrayList;
import java.util.Iterator;

public class concatDemo {
 public static void main(String []args)
 {
     String s1="shashi kumar";
     String s2="shankar";
     char name1[]=s1.toCharArray();
     char name2[]=s2.toCharArray();
     concatination(name1,name2);
   
   
 }
 public static void concatination(char[] name,char[] name1)
 {
     ArrayList<Character> list=new ArrayList<Character>();
     for(char s:name)
     {
         list.add(s);
     }
     for(char s:name1)
     {
         list.add(s);
     }
     Iterator<Character > i=list.iterator();
     while(i.hasNext())
     {
         System.out.print(i.next());
     }
 }

}


output:
--------------------------------
shashi kumarshankar

Thứ Hai, 25 tháng 8, 2014

Matrix problem in java.

problem: 

            Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.

for example:

A matrix of order 3X3 contains elemennts like 

124
037
598

after performing algorithm out put will be

024
000
098


solution:


package logics;

public class matrixProblem {
    public static void main(String []a)
    {
        int [][]data=new int[][]{{1,2,4},{0,3,7},{5,9,8}};
        System.out.print("Before completing task \n");
        printdata(data);
        getdata(data);
    }

public static void getdata(int [][] mat)
{
    int rowlength=mat.length;
    int collength=mat[0].length;
    int row[]=new int[rowlength];
    int col[]=new int[collength];
    for(int i=0;i<rowlength;i++)
    {
            for(int j=0;j<collength;j++)
            {
                if(mat[i][j]==0)
                {
                    row[i]=1011;//am setting reference as 1011  where i need to set 0 .
                    col[j]=1011;
                }
            }
   
    }
    for(int i=0;i<rowlength;i++)
    {
            for(int j=0;j<collength;j++)
            {
                if(row[i]==1011 || col[j]==1011)
                {
                    mat[i][j]=0;
                }
            }
    }
    //printing matrix
    System.out.print("After completing task \n");
    printdata(mat);
}
public static void  printdata(int [][]data)
{
    for(int i=0;i<data.length;i++)
    {
        for(int j=0;j<data[0].length;j++)
        {
            System.out.print(data[i][j]);
        }
        System.out.println();
    }
}
}//class



 output:

------------------------------------------------
Before completing task
124
037
598
After completing task
024
000
098
 

 

Finding Common Elements Of Two Arrays using java

Hi  Guys,

for example array1=[1,2,3,4,5,6] ,array2=[4,5,6] then  your program need to give output as [4,5,6].

Solution:

Here am giving two solutions one by using an iteration method ,other one is using collections.

solution1:
----------------------------------

package logics;

public class comonBetweenTwoArrays {
    public static void main(String []a)
    {
        int first[]=new int[]{1,2,3,4,5,6,7};
        int second[]=new int[]{4,5,6,7,8,9,0};
        for(int i=0;i<first.length;i++)
        {
            for(int j=0;j<second.length;j++){
                if(first[i]==second[j])
                {
                    System.out.print(first[i]);
                }
            }
        }
    }

}
output:

----------------------
4567



solution2:
--------------------------------------

package logics;
import java.util.*;
public class commonnInArraysUsingHastSet {
    public static void main(String []a)
    {
        Set<Integer > s=new HashSet<Integer>();
        Set<Integer> common=new HashSet<Integer>();
       
        int first[]=new int[]{1,2,3,4,5,6,7,8,9,10};
        int second[]=new int[]{0,4,5,6,7,8,9};
        for(int index:first)
        {
            s.add(index);
        }
        for(int c:second)
        {
            if(s.contains(c))
            {
                common.add(c);
            }
                           
        }
        //printing common values
        Iterator<Integer> i=common.iterator();
        while(i.hasNext())
        {
            System.out.print(i.next());
        }
       
    }
}

output:
-------------------
456789

finding First Two maximum numbers in an array

This is very simple program.

let arr[]={1,2,333,44}; out put will be 333,44 where 333 is first max number and 44 is second max number.

logic:just sort the array and return last two elements.[you can sort array by using any sort method ].Here am telling you a one line code for sorting.

---> java has a class called Arrays .you can use Arrays.sort(array) to sort elements in user defined array.

program:


package logics;
import java.util.*;

public class twoMax {
public static void main(String []a )
{
   
    int arr[]=new int[]{1,22,33,222,0,66};
    Arrays.sort(arr);
    int firstMax=arr[arr.length-1];
    int secondMax=arr[arr.length-2];
    System.out.print("first max is"+firstMax+"\n second max is"+secondMax);
   
}
}
 

output:
---------------------------
first max is222
 second max is66


 
 

Java Program To Find Repeating characters in String

For example if a string like"shashi kumar" ,we need to find repeating characters i'e 
s repeated 2 times,a repeated 2 times,h repeated 2 times.

Solution:

1.Basically you can do thing using bruteforce approach  but it takes probably O(n^2) time .
2.For an efficiency you can do this in O(n) if you use collection frame Work.
3.Here am using HashMap() class of collection frame work ,which was defined in java.util package.
 4.The logic here is , first converting string to a character array ,then inserting it into hashmap(key,value) pair.
5.The insertion process in such a way that if a value is already present in map ,am increasing th count by using get(character)+adding1.

program:

package logics;
import java.util.*;

public class repeatingCharactorsInString {

    public static void  main(String []args)
    {
        String data="shashi kumar";
        char ch[]=data.toCharArray();
        Map<Character, Integer> m=new HashMap<Character, Integer>();
        for(char c:ch)
        {
            if(m.containsKey(c))//checking already have been there in a string
            {
                m.put(c, m.get(c)+1);
            }
            else
            {
                m.put(c, 1);
            }
        }
        //now printing repeated values.
        Iterator<Character> i=m.keySet().iterator();
        while(i.hasNext())
        {
            Object key=i.next();
            Integer val=m.get(key);
            if(val>1)
            {
            System.out.println(key+" repeated ----->"+val);
            }
        }
       
    }
}

output:
-----------------------------
s repeated ----->2
a repeated ----->2
h repeated ----->2


 

Java Program To converting a decimal to binary and back to decimal

package logics;

public class decimalToBinary {
    public static void main(String []a)
    {
       
        convert(3);
    }

public static void convert(int dec)
{

    int barray[]=new int[32];
    int index=0;
    while(dec>0)
    {
        barray[index++]=dec%2;
        dec=dec/2;
    }
    System.out.println("binary equivalant is");
    for(int i=barray.length-1;i>=0;i--)
    {
        System.out.print(barray[i]);
    }
    /* converting again into decimal*/
    System.out.println("\nDecimal equivalant is");

    int sum=0;
    int pow=0;
    for(int i=0;i<barray.length-1;i++)
    {
       
        sum=sum+(barray[i]*(int)Math.pow(2.0,pow ));

        pow=pow+1;
    }
    System.out.print(sum);
   
}
}//class


output:
--------------------------
binary equivalant is
00000000000000000000000000000011
Decimal equivalant is
3

Java Program to find Biggest Of Three Numbers Using Ternary Operator(?:)

package logics;

public class biggestTernery {
     public static void main(String []args)
     {
         int res=biggest(10,1300,600);
         System.out.print(res);
     }
public static int biggest(int a,int b,int c)
{
    return ((a>b)&&(b>c)? a :(b>c)?b:c);
}
}//class


output:
--------------------
1300

Java Program to find a duplicate number in an array.

package logics;

public class findDuplicate {
public static void main(String []args)
{
    int arr[]=new int[]{1,2,3,4,5,6,7,8,1,8};
    duplicate(arr);
}

public static void duplicate(int a[])
{
    for(int i=0;i<a.length;i++)
    {
        for(int j=i+1;j<a.length;j++)
        {
            if( (i!=j) &&  a[i]==a[j])
                System.out.printf("duplicate is %d \n",a[i]);
        }
    }
}
}//clas
s

output:
-------------------
duplicate is 1
duplicate is 8

java program to perform string reverse using Recursion

package logics;

public class reverseUsingRecurtion {

    public static void main(String []a)
    {
        String name="shahi kumar";
       
        System.out.print(reverse(name));
    }

public static String reverse(String data)
{
    if(data.length()==1)
        return data;
   
    String rev="";
   
    rev=rev+data.charAt(data.length()-1)+reverse(data.substring(0,data.length()-1));
    return rev;
       
   
}
}//class

output
---------------
ramuk ihahs

Java program to perform string reverse using Iteration

package logics;

public class stringReverseIteration {

    public static void main(String []a)
    {
       
        String name="shashi kumar";
        reverse(name);
    }


public static void reverse(String data)
{
    for(int i=data.length()-1;i>=0;i--)
    {
        System.out.print(data.charAt(i));
    }
   
}
}//class


output
--------------------
ramuk ihsahs

Java program to find sum of pairs of an array.

You have given an array of some elements  say{a1,a2,a3,.......,an}.and you also given a sum to check 'k' .Now you need to find pairs like (a1,a2,....,an)is equal to k
Example:

int arr[]={0,1,2,3,4,5,6}; and sum is 5;
solution is :
pairs are(1,4)   ,(2,3) , (0,5)

----------------------------------------------------------------------------------
Here is the solution for above problem in JAVA.



package logics;


public class sumArray
{
    public static void main(String []ar)
    {
        sumArray m=new sumArray();
        int data[]=new int[]{0,1,2,3,4,5,6};
        m.checkSum(data,5);
      
    }
   

public void checkSum(int a[],int num)
{

    System.out.print("pairs are \n");
    for(int i=0;i<a.length;i++)
    {
        int first=a[i];
        for(int j=i+1;j<a.length;j++)
        {
            int second=a[j];
            int sum=first+second;
            if(sum==num)
            {
                System.out.printf("(%d,%d)\n",first, second);
            }
        }
    }
   
}
}//class


output:
----------------
pairs are
(0,5)
(1,4)
(2,3)
 

Thứ Tư, 20 tháng 8, 2014

Changing "CSS" styles using "JAVASCRIPT"

It's very simple to change css styles using javascript.First you need to get object of DOM i'e you need to have a document object element,Finally change document element style using document.style."cssproprty"

example;

am just taken a sample text ,i changes the color of text into red by using css property color='red'.


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Changing Style</title>
<script type="text/javascript">
function data()
{
document.getElementById('content').style.color='red';
}
</script>
</head>
<body onload="data()">
<center><i id="content">This information is accessed via javascript</i></center>

</body>
</html>
output
===========


Single Linked List Program in "C"

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct link
{
  int data;
  struct link *ptr;
}*head=NULL;

void insert()
{
  char point;
  do
  {
    struct link *newlink,*currentlink;
    newlink=(struct link*)malloc(sizeof(struct link));
    printf("\nEnter data into linked list");
    scanf("%d",&newlink->data);
    newlink->ptr=NULL;
    if(head==NULL)
    {
      head=newlink;
      currentlink=newlink;
    }
    else
    {
      currentlink->ptr=newlink;
      currentlink=newlink;
    }
    printf("\nDo you want to continue?");
    point=getche();

  }while(point!='n');

}
void display()
{
  struct link *iterator;
  iterator=head;
  printf("\n Data in your linked list is");
  while(iterator!=NULL)
  {
    printf("%d----->",iterator->data);
    iterator=iterator->ptr;
  }
  printf("NULL");
}
main()
{

  insert();
  display();
  return 0;

}

output
----------------------------------

Thứ Ba, 19 tháng 8, 2014

Applying Styles to child selectors in CSS


This Concept is very useful  if you ever tried to apply styles child elements of parent.

for example,lets have a program .I defined my text in <strong> element as  a single selector as well as a child selector of a <div> element.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Css demo</title>
<style type="text/css">
strong
{
background-image: url('images/back10.jpg');
font-size: 200%;
text-decoration: underline;
}
div > strong                                                                     / * child selector*/
{
font-size: 300%;
text-decoration: none;
color:yellow;
}

</style>
</head>
<body>

<center><strong>this is a data taken as an example</strong></center>
<br>
<br>

<div>
<strong>this text defined  in a division tag ,which is called as a parent to this element </strong>
</div>
</body>
</html>



 output:


Thứ Hai, 18 tháng 8, 2014

java code to find similar words in "AMITABH BACHCHAN" and "RAJNIKANTH"


import java.lang.*;
public class similar
{

static void find(String s1,String s2)
{
    StringBuffer buf1 = new StringBuffer(s1);
    StringBuffer buf2 = new StringBuffer(s2);
    int count=0;
    int l=0,q=0;
    int[] arr=new int[30];
    int[] arr1=new int[30];//required minimum size 26
    for(char j='A';j<='Z';j++)     
       
    {
        for(int i=0;i<buf1.length();i++)
        {
            if(buf1.charAt(i)==j) //compare the string1 indexes  with Alphabets
            {
                count++; //count similar alphabets
            }
    }
        arr[l]=count;
        count=0;
        l++;
    }   

    for(char j='A';j<='Z';j++)
    {
        for(int i=0;i<buf2.length();i++)
        {
            if(buf2.charAt(i)==j)//compare the string2 indexes  with Alphabets
            {
                count++; //count similar alphabets
            }
        }
        arr1[q]=count;
        count=0;
        q++;
    }
StringBuffer answer=new StringBuffer();
    count=0;
    int f=0;
    for(char ch='A';ch<='Z';ch++)
    {
        if(arr[f]!=0&&arr1[f]!=0)
        {
            count++;
            answer.append(ch);
        }
        f++;
    }
//print the common string
    System.out.println(answer);//Contain the string with common alphabets


    }
public static void main(String[] args)
{
String s1=new String("AMITABH BACHCHAN");
String s2=new String("RAJNIKANTH");
find(s1,s2);
}
}


output
AHINT


Accessing Private data of another class[Extreme logic program]

you all know very well java does'nt allow you to access private variables and methods outside the class.However ther is some loopholes in java "TO DO THIS".

consider a sample class:

private.java



public class privatedata {
    private void message()
    {
        System.out.print("This message was derived from private data");
    }
    private void message(String data)
    {
        System.out.print("your message is"+data);
    }

}

now am accessing private method from outside class "LETS ROCKZZZZ"

import java.lang.reflect.*;
public class accssingprivatedata {
    public static void main(String args[])
    {
        try
        {
            Class c=Class.forName("privatedata");
            Object obj=c.newInstance();
            Method m=c.getDeclaredMethod("message", null);
            m.setAccessible(true);
            m.invoke(obj, null);
        }
        catch (Exception e) {
            // TODO: handle exception
        }
       
    }

}




A simple java program to sort list of names of an array.

import java.util.Scanner;


public class namesort {
    public static void main(String []args)
    {
       
        Scanner sc =new Scanner(System.in);
        System.out.print("How many names you want to sort");
        int len=sc.nextInt();
        String names[]=new String[len];
        String temp=new String();   
        for(int i=0;i<len;i++)
        {

            System.out.print("enter "+i+"name");
            names[i]=sc.next();
           
        }
        //sorting data
        for(int outer=0;outer<names.length;outer++)
        {
            for(int inner=outer+1;inner<names.length;inner++)
            {
                if(names[outer].compareTo(names[inner])>0)
                {
                    temp=names[outer];
                    names[outer]=names[inner];
                    names[inner]=temp;
                }
               
            }
        }
        for(String s:names)
        {
            System.out.println(s);
        }
       
    }

}