Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why cant final, synchronised keyword's cannot be used with constructors  RSS feed

 
Satish Kota
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why cant a constructor be final ?

why cant a constructor be synchronised?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why cant a constructor be final ?

Constructors are not inherited, so it wouldn't make sense for a constructor to be declared final.

why cant a constructor be synchronised?

Because it makes no sense for constructors; it's never necessary. There will never be two threads constructing the same object.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Satish Kota:
Why cant a constructor be final ?

why cant a constructor be synchronised?


Assume they can be final and/or synchronized. Now, what exactly would it mean? It should be obvious if you have a clear understanding of what these keywords mean. Perhaps the existing definition of final and synchronized is unclear and you need to rephrase the question in this context?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!