f



"A" is not equal "A"?

I was trying to convert String Array to String A through cycle and than compare the result with String B but eventhough results were the same it returned false.
I'am working in BlueJ 3.1.0
Code is:
public boolean Method ()
{
   String[] Example = {"a","b","c"};
   String A = "";
   String B = "abc"
   for (int i = 0; i<3 ; i++)
   {
      A = A + Example[i];
   }
   if (A == B)
   {
      return true;
   }
}
never got true...
0
245dav
4/8/2014 1:01:01 AM
comp.lang.java.programmer 52711 articles. 1 followers. Post Follow

4 Replies
1485 Views

Similar Articles

[PageSpeed] 25

I appreciate any suggestions how to solve this
0
245dav
4/8/2014 8:12:45 AM
Den 08.04.2014 10:06, skrev 245dav@gmail.com:
> String[] Example = {"a","b","c"};
>    String A = "";
>    String B = "abc"
>    for (int i = 0; i<3 ; i++)
>    {
>       A = A + Example[i];
>    }
>    if (A == B)
>    {
>       return true;
>    }

http://lmgtfy.com/?q=How+do+I+compare+strings+in+Java%3F
0
Torsten
4/8/2014 9:29:23 AM
Thank you so much :)
0
245dav
4/8/2014 1:49:06 PM
On Tue, 8 Apr 2014 01:06:37 -0700 (PDT), 245dav@gmail.com wrote,
quoted or indirectly quoted someone who said :

>   }
>   if (A == B)

1. variables begin with a lower case letter.
2. see http://mindprod.com/jgloss/string.html#COMPARISON
-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)
0
Roedy
4/8/2014 3:45:03 PM
Reply: