Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

puzzle about equals

 
pamela lee
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer i= new Integer(4);
if i use i.equals(4),what process will do?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i.equals(4) will not compile because the equals method only accepts Objects and not primitive values.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic