This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Method with Object as a Parameter  RSS feed

 
Jackson Martin
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Now my question is : method takes object argument then why primitive datatypes are also able to run that method. If I am passing primitive data types then it also accept it and execute method.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java does something called "auto-boxing" that effectively wraps your primitive up into an object.
 
Jackson Martin
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:Java does something called "auto-boxing" that effectively wraps your primitive up into an object.


Okay thanks got it.
java performs auto boxing and converts primitive datatypes to Object. hence they are able to execute method.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!