Compare two string literals

public boolean compare(String text1, String text2){  
if(text1\=\="" && text2!\="")  
   text1\=null;  
if(text2\=\=""&&text1!\="")  
   text2 \= null;  
if (text1\=\= null && text2\=\=null)   
         return true;  
if (text1.length()\=\=0 && text2.length()\=\=0)   
         return true;  
if (text1.length()\=\=0 || text2.length()\=\=0)   
         return false;  
if (text2\=\=null || text2\=\=null)   
        return false;  
  
      return text1.compareTo(text2);  
  
  
}  


See also