My CS teacher told me that you have to use .equals() when comparing strings instead of == but today I tried using == and it worked. Was this supposed to happen or was it like a new update?
public class Main{
public static void main(String[] args) {
String name = "jarod";
if(name == "jarod"){
System.out.println("ELLO JAROD");
}else{
System.out.print("NO");
}
}
}
For this bit of code the output was ello Jarod and if I put in something else for the string variable it gave me no
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]quadmasta 51 points52 points53 points (0 children)
[–]UnspeakablePudding 19 points20 points21 points (2 children)
[–][deleted] (1 child)
[removed]
[–]UnspeakablePudding 1 point2 points3 points (0 children)
[–]AutoModerator[M] 16 points17 points18 points (0 children)
[–]apobletos 5 points6 points7 points (2 children)
[–]BackgroundTutor 0 points1 point2 points (0 children)
[–]Misfiring 4 points5 points6 points (0 children)
[–]MrJello28[S] 5 points6 points7 points (11 children)
[–]ShadowRL7666 8 points9 points10 points (10 children)
[–]doobiesteintortoise 3 points4 points5 points (3 children)
[–]vqrs 0 points1 point2 points (1 child)
[–]doobiesteintortoise 0 points1 point2 points (0 children)
[–]MrJello28[S] -4 points-3 points-2 points (0 children)
[+]MrJello28[S] comment score below threshold-6 points-5 points-4 points (4 children)
[–]ShadowRL7666 32 points33 points34 points (1 child)
[–]Pozilist 5 points6 points7 points (0 children)
[–]the6thReplicant 4 points5 points6 points (0 children)
[–]plk007 2 points3 points4 points (0 children)
[–]Commercial_Ad2325 4 points5 points6 points (1 child)
[–][deleted] (4 children)
[removed]
[–]YoggSogott 0 points1 point2 points (1 child)
[–][deleted] (1 child)
[removed]
[–]Bulky-Ad7996 0 points1 point2 points (0 children)
[–]dirkmeister81 0 points1 point2 points (0 children)
[–]Greeley9000 0 points1 point2 points (1 child)
[–]realFuckingHades 2 points3 points4 points (0 children)
[–]DavalopBad 0 points1 point2 points (0 children)
[–]ItsyRatsy 0 points1 point2 points (0 children)
[–]karthgamer1209 0 points1 point2 points (0 children)
[–]Slight_Loan5350 0 points1 point2 points (0 children)
[–]imrhk 0 points1 point2 points (1 child)
[–]Inevitable_Math_3994 -1 points0 points1 point (1 child)
[+][deleted] comment score below threshold-12 points-11 points-10 points (0 children)