Saturday, 28 February 2015

insertion sort


for(int i=1;i<n;i++)
{
   temp=a[i];
  j=i-1;
while(temp<a[j] && j>=0)
{
a[j+1]=a[j];
a[j]=temp;
--j;
}

Tuesday, 3 February 2015

final,finally,finalize(); difference


A.final

       final is keyword which is used to restrict to user.final can be used to :
     
       1.variable
       2.method
       3.class
 

1.final variable

         If you make variable ad final.you can not change the the value final variable.

2.final method

            If you make any method as final, you cannot override it.

3.final class

         If you make class as final, you cannot extend it.

B.finally  

    finally is block which is associate with try, catch block.
   E.g.

   try
       {
       //code
        }
catch
      {
        //code
      }
finally
      {
        //code
      }

C. finalize();

    finalize() is method which is defined in object class. garbage collaction is invoke to clean up activities before destroying the object.

Thursday, 29 January 2015

this keyword in java

this is java keyword .this is reference variable that refer to current object.
1. this keyword is used to refer current class instance variable.
2. this() can be invoke current class constructor.
3.using this keyword invoke the current class method
     

Wednesday, 10 December 2014