Java to learn - how to type and whether the string comparison strings are equal from the keyboard

Recently in learning Java, or white stage, the time to do a job today to get keyboard input string, or starting a Scanner, but to use next. (), Directly on the map now.

This question was asked us to compare strings for equality, I started direct comparison sc.next () == "admin", but found he did not like how equal, I Baidu a moment, as if he is sometimes this is more, sometimes not, because he is the comparison of address, if you want to compare two values ​​are equal should use equals (), as shown above

Guess you like

Origin www.cnblogs.com/zlszls3113373723/p/11388790.html