Q:

Error while printing out arraylist elements

Here is a small program which adds and print out workers. When calling a method to print I receive an output with identical elements as many times as the number of elements I have added. I cant understand where is my mistake.
public class Radnik {
    static List<Radnik> workers = new ArrayList<>();
    private String name;

    public static void main (String []args) {
        Radnik.add();
        for(Radnik r : workers) {
            System.out.println(r);
        }
    }
    public static void add () {
        String name;
        String answer;
        do {
            Scanner s = new Scanner(System.in);
            System.out.println("name");
            name = s.next();
            Radnik f = new Radnik();
            workers.add(f);
            System.out.println("More");
            answer = s.next();
        } while (answer.equals("yes"));
    }
} 

A:

You never set the name to a Radnik.
I would add the constructor Radnik(String name) to initialize name and also add an getter and setter.
System.out.println(r) will only print nonsense because it calls Object.toString(). You have to override toString() or call another method to output something meaningful.

public class Radnik {
    static List<Radnik> workers = new ArrayList<>();
    private String name;

    public Radnik(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "Radnik=[name=\""+name+"\"]";
    }

    public static void main (String []args) {
        Radnik.add();
        for(Radnik r : workers) {
            System.out.println(r);
        }
    }
    public static void add () {
        String name;
        String answer;
        do{
            Scanner s = new Scanner(System.in);
            System.out.println("name");
            name = s.next();
            Radnik f = new Radnik(name);
            workers.add(f);
            System.out.println("More");
            answer = s.next();
        } while (answer.equals("yes"));
    }
} 

