So I am trying to count the number of objects in an ArrayList using just Stream. I am using stream.count but that is only returning 1 where as my list has more than 1 objects. Here is some code:
static ArrayList<Person> people = new ArrayList<>();
void loadCourses(){ // putting Person objects in the list }
public void countPeople()
{
Stream<ArrayList<Person>> stream1 = Stream.of(people);
long l = stream1.count();
System.out.println("Number of people loaded: " + l);
}
Any help is appreciated :)