Tuesday, April 2, 2013

TIP 1 : Always use String.length() == 0 to check if String is empty

There are many ways to compare the empty string in java and a usual approach is use below code

 String str = "";  
 if(str.equals(""))  
 {  
   //do something  
 }else{  
  //do else  
 }  


Well, don't do this ever in future. It cost your very high. See the analysis in given link in my another blog.

http://howtodoinjava.com/2013/03/31/always-use-length-instead-of-equals-to-check-empty-string-in-java/

Hello world post !!

Hello all,

I am Lokesh gupta from India. I am a java developer with more than 6 yrs of experience.
I will be writing in this blog about many facts and cheats which will help you in code optimization on runtime.

So keep watching !!