• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reflection  RSS feed

 
deepshree pat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reflecion can be used widely . i want to know how we can use this reflection and how?
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sun Tutorial
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reflection is primarily used by frameworks that need to somehow interact with your code.

imagine a method that makes a copy of a java bean. When creating this method, nobody knows what properties the bean will contain, so you need to figure out a way how to dynamically get a hold of all properties.

This is where you would use reflection. Note that unless you really know what you are doing, don't use it. It violates pretty much every rule of good OO design, as for instance private members can reflectively be made public etc.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!