package br.uff.puro.dc; class MinhaLista { T objeto; MinhaLista proximo; public MinhaLista(T obj) { objeto = obj; proximo = null; } public MinhaLista add (T obj) { MinhaLista aux = new MinhaLista(obj); aux.proximo = this; return aux; } public void imprime() { MinhaLista aux = this; while (aux != null) { System.out.println(aux.objeto + "\n"); aux = aux.proximo; } } } class Aluno { int matr; double cr; String nome; public Aluno(int matr, double cr, String nome) { super(); this.matr = matr; this.cr = cr; this.nome = nome; } public String toString() { return matr + " " + cr + " " + nome; } } public class Lista { public static void main(String[] args) { MinhaLista ml = new MinhaLista(new Aluno(1, 10, "Kildare")); ml = ml.add(new Aluno(2, 10, "Shock")); ml.imprime(); } }