Skip to content
Advertisement

Java(8): How to extract an specific class item from objects array?

I need to work on an Objects array which has the following value:

JavaScript

The code which creates the objects array is:

JavaScript

I need to extract a value from the ApplicationConfiguration type item.

Note that it is not always the first array item!

For start, I tried to do the following:

JavaScript

in order to get a list with the specific item. For some reason I got an empty list.

Why?

Advertisement

Answer

objectsArray contains map entries, and you need to filter the values of those entries.

JavaScript

Of course, it would be cleaner if you changed

JavaScript

to

JavaScript

so that you can write:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement