!= string comparison
Created by: sebastiancoteanu
if (newActivatedThemeId != activatedThemeId) { activateTheme(newActivatedThemeId); }
The code above existing in ThemeServiceImpl.Java will not give the outcome wanted as it uses != to compare strings. != will always be true because the strings data point to different memory locations and != checks for same reference. Therefore, !string1.equals(string2)
is recommended here. .equals
compares values rather than references, so if the strings above have the same value, it will evaluate to false.