I have a List. I want to get the index of the (first) user in the stream with a particular username. I don\'t want to actually require the Us
You can try StreamEx library made by Tagir Valeev. That library has a convenient #indexOf method.
This is a simple example:
List users = asList(new User("Vas"), new User("Innokenty"), new User("WAT"));
long index = StreamEx.of(users)
.indexOf(user -> user.name.equals("Innokenty"))
.getAsLong();
System.out.println(index);