Reflection accessing subclass

A

askmax

Hi,

Can anyone please tell me how I would access a subclass members with
reflection.
So for example:

public class MyTestClass
{
public class SourceObj
{
String mytest1;
}

String mytest1;
int mytest2;
long mytest3;
List<String> mytest4 = new java.util.ArrayList<String>();
HashMap<String,String> mytest5 = new HashMap<String, String>();
SourceObj mytest6 = new SourceObj();
}

I want to set the value of mytest6.mytest1

Thanks,
Max
 
D

Daniel Pitts

Hi,

Can anyone please tell me how I would access a subclass members with
reflection.
So for example:

public class MyTestClass
{
public class SourceObj
{
String mytest1;
}

String mytest1;
int mytest2;
long mytest3;
List<String> mytest4 = new java.util.ArrayList<String>();
HashMap<String,String> mytest5 = new HashMap<String, String>();
SourceObj mytest6 = new SourceObj();
}

I want to set the value of mytest6.mytest1

Thanks,
Max
mytest6.mytest1="Foo".
 
E

EJP

Can anyone please tell me how I would access a subclass members with
reflection.

I want to set the value of mytest6.mytest1

So go ahead. But mytest6 is a SourceObj, which isn't a subclass of
anything except Object.

What is your *actual* problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top