• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

constructors

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!!! all
i am new to JAVA
pls anybody throw a light on this...
how object initialization is effected
when we declare constructors to be private or public.
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,I really appreciates ur question...so
well i am also not a very old java guru,, but i am sure it wont make any abnormal effects on object initializtion...
it will work just the same way as it works when the Constructor was declared public...
do me a favour when u get an answer ( a solid one) do mail it to me:
Name: Azam Bukhari
Email: sazam@email.com

Originally posted by amrit singh:
hi!!! all
i am new to JAVA
pls anybody throw a light on this...
how object initialization is effected
when we declare constructors to be private or public.



------------------
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only thing that is affected is the access to the constructor function. Private constructors can only be called within the same class. Meaning that a new object cannot be initialized if it is done outside of the class in which the constructor is declared. However a public constructor can be called from any location. Private constructors are predominantly used when programmers want to put constraints on the creation instantiation of objects.
Hope that helps!
 
amrit singh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanxx for ur reply
it really helped alot.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!