I think your interpretation of the code is wrong. Probably not thinking about how it runs, I imagine you think it puts words and magically something happens. Everything that is written has a consequence and you have to understand the whole process, otherwise you will not learn to program.
Let's understand what happens with the list:
On line
List<String> lista = new ArrayList<>();
A list of strings is created and is referenced by a variable called lista
.
On the following lines
lista.add("Aline");
lista.add("João");
lista.add("Jona");
lista.add("Pedro");
elements are added to this list.
Finally on the line
return lista;
The list is returned to the caller. The variable lista
no longer exists, but the object pointed to by it, in case the list with 4 elements still exists and will be pointed by the one who called this method.
Now we return to the main method. In the line
Teste1 t = new Teste1();
An object of type Teste1
is created and placed in the variable 't'. Actually there would not have to be an object just for this, but come on.
On line
dados = t.getList();
The method is called and its return, that our list is passed to the variable data that had already been declared. So now dados
passes the list that was in the lista
variable inside the getList()
method.
Finally the line
System.out.println(dados);
prints the list.
You do not need another new
anywhere because you only need to create the list once. There is nothing to "accumulate" because the code does not have to do this. If he had it done then he would. It would even be impossible to have [Aline, João, Jona, Pedro Aline, João, Jona, Pedro, Aline, João, Jona, Pedro]
because only a list with only 4 elements was created.
You need to understand what the code is doing but keep repeating ready codes and you do not know what you're doing.
I even imagine you want to do other things, but the question does not even talk about it. Before programming it is necessary to understand the problem and express it in Portuguese. If this can not be done, it is certain that in Java it will not be right, since the base is wrong.