I am trying to loop through an array of objects but when trying to print it all I see is something like this
com.company.resources.datastructures.Preference@7db93e1a
I am converting an Oracle Cursor into this array of objects and it looks fine in the REST service response.
[
{
"preferenceId": "1",
"preferenceValue": "N",
},
{
"preferenceId": "2",
"preferenceValue": "Y",
},
{
"preferenceId": "3",
"preferenceValue": "N"
}
]
however I don't know how to properly iterate through this array of objects in Java.
Say preferencesFromCursor already coverted the cursor into array of objects.
Preference[] preferences = preferencesFromCursor;
for(Preference p : preferences) {
System.out.println("p.toString() = " + p.toString());
}
My expected result is to replace each preferenceValue
in the objects from "N" to false and "Y" to true.
I can't even properly output the object so I'm not even progressing with the conversion.
Should it look like this?
if(p.getPreferenceValue() == "Y") {
p.setPreferenceValue(true)
} else {
p.setPreferenceValue(false)
}