View Single Post
Old Jan 11th, 2007, 2:57 PM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by fresher View Post
thanks for your reply but is network.trim() a java function
Yes, and a quick Google or a look at the Sun javadocs would tell you all about it

Quote:
Originally Posted by fresher View Post
and what is the meaning of " ".equals..... please? a little comment will be perfect. thanks in advance
To check whether two strings, a and b, are equal, you'd use the following code:
a.equals(b)
If b is null, then the above expression returns false. If a is null, then an exception is raised, because you can't have null.equals(b).

So when comparing a string whose value could possibly be null (i.e. network), against a string whose value cannot be null (i.e. ""), then it's best to have the string that cannot be null as the one on the left, and the string that can be null on the right.

"".equals(stringThatMightBeNull)    // false when null

stringThatMightBeNull.equals("")    // error when null
Arevos is offline   Reply With Quote