[Advanced-java] Performances
Andrew Bacon
arbacon at fedex.com
Thu Jul 3 18:54:29 2003
The main benefit of the latter construct is if your variable is NULL
then the condition is false w/out throwing a null pointer exception.
Performance wise, they are the same.
ARB
Marco Ferretti wrote:
>I there guys, I wonder if someone can point me somewhere. I have always
>coded boolean evaluation on strings like :
>
>String foo = "123";
>
>if(foo.equals("456") ){
>
> ...
>
>}
>
>probably because I code as I think (if the variable equals something ....).
>
>I took a look at sun's code for jdk and always saw the above as
>
>String foo = "123";
>
>if("ss".equals(foo) ){
>
> ...
>
>}
>
>
>
>So : is there some reason (eg. performance) why I should change the way I
>always coded such things ?
>
>
>
>TIA
>
> Marco
>_______________________________________________
>Advanced-java mailing list
>Advanced-java@lists.xcf.berkeley.edu
>http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java
>
>
>