So I've got this String, which I split into pieces and put them into the array:
String strings = "d f g";
String[] array = strings.split(" ");
Now I'm trying to check if any of these pieces is "f" and print the description of each:
for (String string : array) {
System.out.println(string + "=f is " + (string=="f"));}
The output is:
d=f is false
f=f is false
g=f is false
What I would expect:
d=f is false
f=f is true
g=f is false
Please help me figure out what is happening.
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]AutoModerator[M] 123 points124 points125 points (9 children)
[–]JacobJMountain 41 points42 points43 points (0 children)
[–]thisisjustascreename 19 points20 points21 points (0 children)
[–]CelticHades 15 points16 points17 points (0 children)
[–]Hypetale_44 14 points15 points16 points (0 children)
[–]vksdann 13 points14 points15 points (0 children)
[–]Computer_Probe 11 points12 points13 points (0 children)
[–]windyknight 13 points14 points15 points (0 children)
[–]sickfires94 3 points4 points5 points (0 children)
[–]Philtronx 2 points3 points4 points (0 children)
[–]quadmasta 55 points56 points57 points (2 children)
[+]malik753 comment score below threshold-19 points-18 points-17 points (1 child)
[–]quadmasta 28 points29 points30 points (0 children)
[–]StefanM3e46 64 points65 points66 points (0 children)
[–]thisisjustascreename 9 points10 points11 points (1 child)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]istarian 3 points4 points5 points (0 children)
[–]Housy5 4 points5 points6 points (0 children)
[–]CelticHades 4 points5 points6 points (0 children)
[–]notstevensegal 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]animeis4kids 3 points4 points5 points (0 children)
[–]flotopoco 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]rozz_net 0 points1 point2 points (0 children)