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

Reflection API - My program doesn't display the parametertypes of my constructors in the output.  RSS feed

 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My class looks as follows. It compiles without error and when I run it, it doesn't give me in the command line output the list of parameters in the constructors of class MyThread. Could you please advice?

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method getConstructors() returns only the public constructors of a class; MyThread has none, so you get no output. You perhaps want to use getDeclaredConstructors() which returns all constructors, public or not.
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much, Ernest. It's working fine atter the change.
 
Campbell Ritchie
Marshal
Posts: 55691
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch You should always use the code button; I have edited your post so you can see how much better it looks when you used the code tags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!