
03/01/2013, 13:08
|
| | Fecha de Ingreso: noviembre-2009
Mensajes: 40
Antigüedad: 15 años, 2 meses Puntos: 1 | |
Respuesta: printar lista desde otro método public CuentasPrivilegiadas() {
List <Cuenta> cuentas = new ArrayList <Cuenta> ();
cuentas.add(new Cuenta(33631,"password"));
cuentas.add(new Cuenta(6293,"otherpassword"));
}
En tu constructor estas declarando una nueva variable cuentas, por lo que no usas la que declaraste como variable de clase, y esta queda en todo momento nula
Debería ser algo asi tu constructor.
public CuentasPrivilegiadas() {
this.cuentas = new ArrayList <Cuenta> ();
this.cuentas.add(new Cuenta(33631,"password"));
this.cuentas.add(new Cuenta(6293,"otherpassword"));
}
Saludos!! |