Q:

How can I search informations from file with names using input (java)?

(I copy-pasted the whole code, but you just have to look at line 28 to 45)
We have to input the surname and the firstname to get the number of votes that the actual person got.
I wrote a code and if I type in the input the first row surname firstname it works nicely(I get 19, which on is the correct number), but every time when I try to write another name in the input field it doesn't work.
Inside the file there are 5 cloumns, (1st and the 5th is unnecessary in this problem)
2.cloumn we have votes that a person got
3.column we have surnames and obviously in the 4.cloumn we have first names.
kepviselok.txt
expected and actual output
    package erettsegi2;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
        var lista = Files.readAllLines(Paths.get("kepviselok.txt"));
        var listak = new ArrayList<Lista>();
        var input = new Scanner(System.in);

        for (var valaszt : lista) {
            String[] split = valaszt.split(" ");
            var kerSzam = Integer.parseInt(split[0]);
            var szavazottSzam = Integer.parseInt(split[1]);
            var nev = split[2] + " " + split[3];
            var part = split[4].equals("-") ? "Independent " : split[4];

            listak.add(new Lista(kerSzam, szavazottSzam, nev, part));
        }
        System.out.println("2.");
        System.out.println("Number of Representatives on Election: " + listak.size());

        System.out.println("3.\nPlease write a surname!");
        var surname = input.nextLine();
        System.out.println("Please write a first name!");
        var firstname = input.nextLine();

        for (var i = 0; i < listak.size();i++) {
            var actualCandidate = listak.get(i);

            if (actualCandidate.name.equals(surname + " " + firstname)) {
                System.out.println(actualCandidate.name);
                System.out.println("Number of votes " + actualCandidate.votes);
                break;
            } else {
                System.out.println("No candidate with this name");
                break;
            }
        }

    }

    static class Lista {
        int sorszam;
        int votes;
        String name;
        String part;

        public Lista(int sorszam, int szavazatokSzama, String nev, String part) {
            this.sorszam = sorszam;
            this.votes = szavazatokSzama;
            this.name = nev;
            this.part = part;
        }

    }
}

A:

Take a look on your code, in the last cycle you have condition if-else and this condition will finish the cycle if first candidate name not equals (else executed, and you have break inside it) or this condition will finish the cycle because you found candidate in the first line (if block executed). It means that you are checking only first entry of your list, then cycle finishes because if or else block executed.
So, correct solution will be move print of "No candidate with this name" outside of cycle if you haven't found candidate (I added boolean candidateFound variable for this purpose), because only after check of whole list you can state that:
boolean candidateFound = false;
for (var i = 0; i < listak.size(); i++) {
    var actualCandidate = listak.get(i);

    if (actualCandidate.name.equals(surname + " " + firstname)) {
        System.out.println(actualCandidate.name);
        System.out.println("Number of votes " + actualCandidate.votes);

        candidateFound = true;
        break;
    }
}

if (!candidateFound) {
    System.out.println("No candidate with this name");
}

