equals() - String Comparison

Q

What would you use to compare two String variables - the operator == or the method equals()?

✍: FYIcenter

A

You can use operator == and method equals() for different types of comparisons:

  • Using operator == to compare two string variables to see if they point the same String object.
  • Using equals() to compare two string variables to see if they contain the same String values.

2007-03-03, 6475👍, 0💬