0

the code is

Field field = st.class.getField("g_"+selectedGroup);

st is my class, and g_+"selectedgroup" is in the st class as String array

how to get that string array?

I need something: String sa[]= field.getStringArray[]; but only getInt, getBoolean there is :(

how to?

2 Answers 2

2

Try this,

Field field = ST.class.getField("g_"+selectedGroup);
String[] sa = (String[])field.get(stInstance);

Where stInstance is an instance of ST class.

Sign up to request clarification or add additional context in comments.

Comments

1

You just use get.

field.get(instance);

If it's a static field, instance can be null (or really anything).

1 Comment

You are right, I made a very silly mistake. Now corrected. +1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.