From: askmax on
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
From: John B. Matthews on
In article
<a11ce6b9-8054-4ccf-ab30-9173b5a42ffc(a)f35g2000yqd.googlegroups.com>,
askmax <askmax(a)gmail.com> wrote:

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

Have you looked at <http://java.sun.com/docs/books/tutorial/reflect/>?

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
From: Daniel Pitts on
On 3/1/2010 2:28 PM, askmax wrote:
> 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".


--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
From: EJP on
On 2/03/2010 9:28 AM, askmax wrote:
>
> 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?