Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why and When to use reflections

 
Harsha Hegde
Greenhorn
Posts: 17
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I recently studied the concept of reflections in java, but I am unable to find the practical use of it?
Can anyone give a practical example where some problem can be solved only by reflection or reflection is the best way to sole that problem.
Rgds,
HH
 
Daesung Park
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reflection is widely used, and dependency-injection is one of the examples.
You can describe concrete class name in your configuration file and then create an instance of the class at runtime by reflection.



 
lin qun
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setter and getter methods.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To the Java Tutorials! You will find a whole section about reflection.
 
Kuldeep Tewari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some of the realtime examples include : your IDE's intellisense, Dynamic proxies, dependency injection etc.
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
intermediate level!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic