== might work the same as equals()

It’s a rule that == is used to compare references, not values. To compare values for equality equals() method should be used.
However, as of Java 5, you can also use == to check if two objects’ values are the same… But it works only for the following wrapper objects, if their primitive counterparts’ values are the same:

  • Boolean
  • Byte
  • Character for values: \u0000 (0) ÷ \u007f (127)
  • Byte and Integer for values: -128 ÷ 127
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • bodytext
  • Technorati
  • Reddit
  • StumbleUpon
  • description
  • Wykop
  • Gwar
  • e-mail

0 Responses to “== might work the same as equals()”


  1. No Comments

Leave a Reply