Posts

Java Variable Arguments

Java variable arguments (varargs) was introduced in java 1.5.usage of varargs is  if u want to pass more arguments to the method say example more than 3 or 4 of same data type then we can go for varargs which makes the code simple and neat. Before varargs developer used two options creating a collection like list or set and passing all the data with that overloading  method with different parameter  But we have some disadvantages  in the methods mentioned above lets  take method overloading private int varargsDemo(int i, int j) {         int result =i*j;         return result;     }        private int varargsDemo(int i, int j,int k) {         int result =i*j*k;         return result;     } Here you can see if you use overloading your code becomes little clumsy and y...

Why serialVersionUID Is Required??

Image
   serialVersionUID is used to identify the class during deserialization process.if you don't mention serialVersionUID in your class then  by default JVM will generate it . JVM generated  serialVersionUID will be a 64 bit hash value of class name ,method and fields.But there is a problem in not declaring serialVersionUID manually. Let me explain it with the example ,   This is my class which i want to serialize public class Employee implements Serializable {         /**      *      */     public int getEmpId() {         return empId;     }     public void setEmpId(int empId) {         this.empId = empId;     }     public String getEmpName() {         return empName;     }   ...

Call Handle Bar Helper Function From Another Helper Function

Hi all, This is my new post after long time :P                                I am Learning Handlebar now :) I am not going to explain you the basics of handlebar and make my post as bored one .Instead let me explain the feature which most of us don't know. If you are new to handlebar here is the link you can refer it and learn basics                                 http://handlebarsjs.com/ From the above link you will get to know there is  a feature called helper function in handlebars . Here i am going to explain how to call a helper function from another helper function. some times  you may get into a situation where you want to perform some operation as the result of another in that sit...

Trick To Use Multiple Gtalk Instances.

Image
We may have multiple G talk account but the problem is we cant log in to multiple accounts  at the same time .Here i am going to  give solution for this . Steps: 1.Go to your desktop right click  New->Short Cut 2.You will see following screen 3.Then Give as follows in the text box ,with your  g talk installation location   For example my  g talk  installation l ocation is   C:\Program Files (x86)\Google\Google Talk\googletalk.exe     "C:\Program Files (x86)\Google\Google Talk\googletalk.exe" /nomutex 4.Click Next ,it will show one more text box 5.Just give what ever name you like to give for your another g talk short cut then finish 6.Now you can see the new Shortcut  created fro g talk in your Desktop  7.Click on the shortcut and log in as usual 8.Enjoy Chatting :)

JAXB -Play With XML

Image
JAXB  -Play With XML    (A Simple Example With Explanation)                     JAXB stands for Java Architecture For XML binding.Using this we can Write and Read An XML File .Unlike SAX,DOM no need to have much knowledge on xml parsing . JAXB is  a very easy technique to understand Writing an XML file is called as marshaling Reading an XML file is called as unmarshaling         Let us see the step by step procedure to perform marshaling & un marshaling.          Marshaling  As Mentioned above marshal ing means writing xml fil e form java object. The first step i s creating  java class from a sc he ma.if we have a schema file required we can create pojo cl assess from it using xsd jar. xsd ja r is ava ilable with java by default .xsd is a binding comp iler which is mentioned ...

The Keyword "super"

                                                                                                      The Keyword "super" Consider we are extending a class from another class using inheritance , we always create an object to a sub class..this is because we can access all super class and sub class  members using sub class object.If super class and sub class members have same name by default only sub class members are accessible.. In this case we can use Super Keyword to access super class member. Example1:         Class Mysuper {  int i=10; void show() { System.out.println("super class variable:i="+i); } } Class Mysub extends  Mysuper { int i=20; void show() { ...

WAY TO INCLUDE EXTERNAL JAR FILES(LIB)INSIDE PROJECT JAR

                                 WAY TO INCLUDE EXTERNAL JAR FILES(LIB)IN PROJECT JAR when we create a project using  net beans IDE the jar will be created automatically inside a dist folder which will be located  inside  the project folder itself .But this JAR will not contain the external jars which you have added for your projects.(jars inside the library folder). You can create a project jar that includes the external jars using the following step: 1.Go to the project folder which you  have created using netbeans IDE. 2.create a new folder named ' NewDist'  inside the project folder directory. 3.create a file named ' JarMaker.bat ' in the folder which you craeted( NewDist ). 4.copy the below code in the file. Code: ------- @echo off echo * --------------------------------------------...