• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

private constructor code

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator





In preceding code why we are invoke getDeclaredConstructors() method on both HackMe and class (i.e HackMe.class)?please give me detailed explanation

[edit]Add code tags. CR[/edit]
[ December 19, 2008: Message edited by: Campbell Ritchie ]
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although on the surface this seems to be about an arguably advanced topic -- reflective access to private constructors -- I think it's actually a question about basic Java syntax and reading the API documents.

The syntax "HackMe.class" retrieves the java.lang.Class object that represents the HackMe class. It's a convenient shortcut to the same object returned by the static method call Class.forName("HackMe") . The method getDeclaredConstructors() is a method of java.lang.Class, and so we have to fetch the appropriate Class object to call the method on.
[ December 19, 2008: Message edited by: Ernest Friedman-Hill ]
 
Marshal
Posts: 64629
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope we have made you welcome here, Raj Chiru

Please find the code button and maintain indentation. I have edited your post to add indentation, and you can see how much better it looks.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!