This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inquisition Question

 
Chandana Garlapati
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


why the above code prints false???
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because int[] does not override the equals method.

By default equals method returns true if both the reference are pointing to the same object whcih is not in your case.

To compare arrays use Arrays.equals(arr,arr) method.
 
Chandana Garlapati
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Siva.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic