You can use IntStream.range() (or rangeClosed()) and Stream.toArray() to implement the same logic with Stream API:
Map<Integer, String> people = Map.of(
1, "John", 2, "Michael", 3, "Bob", 4, "Liza", 5, "Anna"
);
String[] names = IntStream.rangeClosed(1, 5)
.mapToObj(people::get)
.toArray(String[]::new);
If the keys of the original map are not integers, or the map is represented by a plain HashMap which is incapable of maintaining the order, but you need to reflect the ordering of keys in the resulting array, then create a stream of entries and sort them by key as suggested by @Holger:
String[] names = people.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(Map.Entry::getValue)
.toArray(String[]::new);
In case if the order of elements is not important, then you can use Collection.toArray():
String[] names = people.values().toArray(String[]::new);
persons.values().toArray(new String[0])?peopleand notresponseItemsas originally posted? Not the best idea to make such changes to posted code IMO! Or did I miss some comment?