Lets say i have a piece of code like that:
String name1 = someObject.getClass().getName();
System.out.println(name1);//The result of println in console is: entities.player.Shotgun
String name2 = someObject.getClass().getSimpleName();
System.out.println(name2);// The result of println in console is: Shotgun
String name3 = someObject.getClass.getName().substring(16);
System.out.println(name3);//The result of println in console is: Shotgun
if(name1 == "entities.player.Shotgun")System.out.println("condition1 true");
if(name2 == "Shotgun")System.out.println("condition2 true");
if(name3 == "Shotgun")System.out.println("condition3 true");
In my opinion all three if clauses are true but in reality only first fires in console: condition1 true. My question is why? What is the problem here?