The problem is that does not see the p variable.

 public class Main { static Collection<Persone> peoples = Arrays.asList(); public static void main(String[] args) { createModelInCollection(100); List<Persone> filtered = peoples .stream() .filter(p -->p.getName().startsWith("Ivan")) .collect(Collectors.toList()); } static void createModelInCollection(int i) { Persone persone = new Persone(); String[] name = { "Ivan", "Kola", "John", "Kate", "Nicole", "Tony", "Alex", "Brandi", "Megan", "Dima", "Frank", "Phil", "Kai", }; String[] lastName = { "Stark", "Aniston", "Kross", "Green", "Akira", "Jemenson", "Freeman", "Stiffler", "Phinch", "Obama", "Sokolov", }; for (int x = 0; x < i; x++) { persone.setAge(random(80)); persone.setName(name[random(name.length)]); persone.setLastName(lastName[random(lastName.length)]); if (x % 2 == 0) { persone.setGender("MAN"); } else { persone.setGender("WOMAN"); } peoples.add(persone); } } static int random(int i) { Random rand = new Random(); return rand.nextInt(i); } } 

Error: Multiple markers at this line - p cannot be resolved - p cannot be resolved to a variable

I use java 8. OS linux enter image description here

Help to understand what the problem is.

  • What error does it write? - iksuy
  • Can an explicit type cast help? - Andrey M
  • `Multiple markers at this line - p cant be resolved - p cant be resolved to a variable - drugs_and_code
  • code example took from here prologistic.com.ua/polnoe-rukovodstvo-po-java-8-stream.html - drugs_and_code
  • studio restarted? - Senior Pomidor

2 answers 2

The problem is in an extra minus / hyphen in p -->p.getName().startsWith("Ivan")

I will note in brackets that the problems are also with the actual type of peoples , with the work of the random method.

    Updated Eclipse to the latest version, everything worked) the problem with the variable p gone. extra minus removed)