troubleshooting Question

Get bean property from bean name in Java

Avatar of Rookierav
Rookierav asked on
JavaJava EE
4 Comments1 Solution151 ViewsLast Modified:
I have a bean with name "MyProps". MyProps bean has a property "ssn".  How to get the property from the bean name? I don't have the reference to the "MyProps" directly.

public class Props {

public class MyProps extends Props {
String a;
double b;
String c;


public class YourProps extends Props {
String d;
String e;
int f;


public class Search {
public static Props googlSrch(String term) {

public static void main (String args[] ) {

Props rtn = googlSrch("getMyProps") ; //MyProps is returned but as a Props
// I want to extract properties a, b, c without casting rtn to MyProps
Props rtn1 =  googlSrch("getYourProps") ; //MyProps is returned but as a Props
//I want to get properties e,f from rtn1

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros