var vector = new Vector<Car>();
vector.add(new Car(..., ..., ..., ...));
var carFromVector = vector.get(0);
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Введите количество строк: ");
var n = Integer.valueOf(in.nextLine());
for (int i = 0; i < n; i++) {
System.out.println("Введите строку: ");
var s = in.nextLine();
var parts = s.split(" ");
var first = parts[i];
parts[i] = parts[parts.length - 1];
parts[parts.length - 1] = first;
var result = String.join(" ", parts);
System.out.println(result);
}
}