I was doing a practice Computer science test and tried this question out.
String sam = "scary"; String ben = new String("scary"); String wil = "scary"; out.print( sam == ben ); out.print( " " + (sam == wil) ); From my knowledge I thought the printouts would be false false because from what I know, strings can only be compared with .equals(). But I got it wrong. It says that the answer was false true. Can someone please explain why?