• Post Reply Bookmark Topic Watch Topic
  • New Topic

Constructor  RSS feed

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
non-static method execute on instance of class, so how is print() being execute without instance of class before Print constructor complete ? How it is valid ? i read we can't access instance variable or make a call to method before constructor complete.
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shalini Srivastav wrote:
how is print() being execute without instance of class before Print constructor complete ? How it is valid ?

every instance methods/constructors has implicit parameter called this object. when you say print() inside an instance method. compiler interprets as this.print()
 
Shalini Srivastav
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i read we can't access instance variable or make a call to method before constructor complete.
then what does it mean ? and do you mean even constructor has this keyword as method has ?
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shalini Srivastav wrote:
i read we can't access instance variable or make a call to method before constructor complete.
then what does it mean ? and do you mean even constructor has this keyword as method has ?


I don't know where you read that (please quote your sources) but it is not a true statement.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!