Because, == checks for address and .equals checks for value


On Dec 30, 2009, at 3:22 AM, Sumant <sumant2...@gmail.com> wrote:

> Why I get True for Equals and false for == ? here is the code below...
>
>
>
> public class Test12 {
>
>
>     public static void main(String[] args) {
>         String str1=new String("abc");
>         String str2="abc";
>         System.out.println(str1.equals(str2)); // Returns True
>         System.out.println(str1==str2); // Returns False
>
>     }
>
> }
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Java EE (J2EE) Programming with Passion!" group.
> To post to this group, send email to
> java-ee-j2ee-programming-with-passion@googlegroups.com
> To unsubscribe from this group, send email to
> java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

Reply via email to