Issue
I was wondering how to get KEY and VALUE from object in JAVA
my object is like below
Object obj = [{ index_a = 1, index_b = 2}, { index_a = 3, index_b = 4}]
I want to get index_a, 1, index_b, 2, ...
Solution
I'm guessing you've come to Java from a language in which objects have loose types and are accessed approximately as key, value pairs which are often defined at run time. An example is json converting directly to JS objects with minimal translation.
That does not describe Java at all. The type and structure of Java objects are explicitly defined at compile time and expected to be accessed through methods available at compile time. For an experienced Java coder, your question is confusing because accessing object variables as keys and values is just not how things are generally done in Java.
If your object is going to store a list of maps from string keys to date values (for example), then that would normally be expressed in java as a variable of type List<Map<String,Date>>
.
Answered By - sprinter
Answer Checked By - Pedro (JavaFixing Volunteer)