Method to add element to a doubly chained list – Java

I am trying to create (I am learning) a double chained list based on an exercise, in which the list will be a train with wagons. The exercise calls for creating a class "wagon", where the variables "name of wagon", "next wagon" and "previous wagon" are found, and another "train" class is created, where the variables "head" "and" tail ", and the methods to add wagons, to print the wagons and another to change the order of the locomotives. My problem is how the exercise asks to create the method to add wagons. A variable that has not been declared is passed as a parameter, with the class "wagon" as data type, so I am not able to create that method. I will show what I did in the following code. Would someone have to give me a clue as to that? I just can not understand how I'm going to use the "vagaoCrear" parameter in the method.

In addition, the exercise asks that two trains be created, then two lists, and using the method to change the locomotives, that the locomotive of the first train be changed with that of the second. I would like to know, is this really possible to do using a double linked list (or in the case, two)? Because I already caught a lot and I did not see anything about it. I saw that it is possible to change the order of the elements of a list, but to change the elements between two lists, I am not sure.

public class Vago {
String name of Vago;
Wagon vagaoAnterior;
Wagon vagaoPosterior;

public vagao (chain chain name) {
this.Vagoname = nameVago;
vagaoAnterior = null;
vagooPosterior = null;
}
}

public class Trem {
Vagao head, tail = null;

// I'm not knowing how to create here
public void add Vagao (Vagoo vago)
New vessel_Vagao = new Vagao (vagaoCreate.VaconName);

if (head == null) {}
head = tail = novo_Vagao;
head.vagaoAnterior = null;
tail.vagaoPosterior = null;
}
} else {
tail.vagaoPosterior = new_Vagao;
new_Vagao.vagaoAnterior = tail;
tail = new_Vagao;
tail.vagaoPosterior = null;
}
}
}