I am trying to create a LinkedList and then create a menu asking to create a Teacher, Show Teacher list.
The thing is that I can create the Teacher object and add it to the LinkedList, but, when I select the Second option, Show Teacher List more than one time without creating a new Teacher, the programs continue to creating objects.

Here is my code:

```
    import java.util.*;
    import javax.swing.JOptionPane;

    public class Prueba {
    public static void main(String[] args) {
    LinkedList<Teacher> teacher = new LinkedList();
    int id, salary,op;
    String name, programm, teacherList ="";

    Teacher t1 = new Teacher();

    op=Integer.parseInt(JOptionPane.showInputDialog("Please, pick an option: \n"
            + "1. Add Teacher. \n"
            + "2. Get Teacher List. \n"
    ));

    while(op!=0){
        if(op == 1){
            id=Integer.parseInt(JOptionPane.showInputDialog("Ingrese ID del docente: "));
            name=JOptionPane.showInputDialog("Ingrese nombre del docente: ");
            programm=JOptionPane.showInputDialog("Ingrese programa del docente: ");
            salary=Integer.parseInt(JOptionPane.showInputDialog("Ingrese salario del docente: "));
            Teacher d = new Teacher(id,name,programm,salary);
            teacher.add(d);
        }else if(op == 2){
            Iterator p = teacher.iterator();
            while(p.hasNext()){
                teacherList = teacherList + "\n"+ p.next();
            }
            JOptionPane.showMessageDialog(null, teacherList);
        }
        op=Integer.parseInt(JOptionPane.showInputDialog("Please, pick an option: \n"
            + "1. Add Teacher. \n"
            + "2. Get Teacher List. \n"
            ));
    }

}

```

}

Class Teacher:

```
public class Teacher {
private int id;
private String name;
private String programm;
private int salary;

public Teacher() {
}

public Teacher(int id, String name, String programm, int salary) {
    this.id = id;
    this.name= name;
    this.programm = programm;
    this.salary = salary;
}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name= name;
}

public String getProgramm() {
    return programm;
}

public void setProgramm(String programm) {
    this.programm = programm;
}

public int getSalary() {
    return salary;
}

public void setSalary(int salary) {
    this.salary = salary;
}

@Override
public String toString(){
    String message;
    message = "Id: "+this.id+" - Name: "+this.name+" - Programm: "+this.programm+" - Salary: $"+this.salary;
    return message;
}

```

}