Why does filter only print 3 times? He doesn't have to loop through it all to know how many strings are three length.

public class LazyStreams {
    private static int length(final String name) {
        System.out.println("getting length for " + name);
        return name.length();
    }
    private static String toUpper(final String name ) {
        System.out.println("converting to uppercase: " + name);
        return name.toUpperCase();
    }
    //...

    public static void main(final String[] args) {
        List<String> names = Arrays.asList("Brad", "Kate", "Kim", "Jack", "Joe", "Mike", "Susan", "George", "Robert", "Julia", "Parker", "Benson");

        final String firstNameWith3Letters = names.stream()
            .filter(name -> length(name) == 3)
            .map(name -> toUpper(name))
            .findFirst()
            .get();

        System.out.println(firstNameWith3Letters);
    }
}

later searched it and said delayed loading, "lazy feature"
so:
final String firstNameWith3Letters = names.stream ()

            .filter(name -> length(name) == 3) //TODO 1, ??? findFirst
            .map(name -> toUpper(name))
            .findFirst()
            .get();
Mar.01,2021

read it wrong. You only need to cycle through a
pair

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e42358-44974.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e42358-44974.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?