Debate sobre ejercicio-carritocompra

1 view
Skip to first unread message

juanant...@gmail.com

unread,
Jan 11, 2008, 12:52:50 PM1/11/08
to ceac-j2ee
Acerca del problema del map.containsKey(product1)
que hemos tenido que implementar el hashcode también además del equals

http://www.google.es/search?q=map+containskey+hashcode&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:es-ES:official

picar en:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html

que trae lo siguiente:
Many methods in Collections Framework interfaces are defined in terms
of the equals method. For example, the specification for the
contains(Object key) method says: "returns true if and only if this
map contain a mapping for a key k such that (key==null ? k==null :
key.equals(k))." This specification should not be construed to imply
that invoking Map.containsKey with a non-null argument key will cause
key.equals(k) to be invoked for any key k. Implementations are free to
implement optimizations whereby the equals invocation is avoided, for
example, by first comparing the hash codes of the two keys. (The
Object.hashCode() specification guarantees that two objects with
unequal hash codes cannot be equal.) More generally, implementations
of the various Collections Framework interfaces are free to take
advantage of the specified behavior of underlying Object methods
wherever the implementor deems it appropriate.

Paco

unread,
Jan 14, 2008, 12:00:26 PM1/14/08
to ceac-j2ee
Hola:
Acerca de este ejercicio tengo dos dudas (para Juan Antonio o el que
sea):
- Con respecto al Controlador en cuanto se realice el ejemplo que
intercepte el addProducto a cesta y delProducto a cesta qué otros se
deberían implementar.

- (Esta si es para Juan Antonio) El viernes Juan Antonio habló sobre
crear una serie de usuarios para que se pasara por un login y una
contraseña. Habrá tipos de usuario o todos son del mismo tipo. Cómo se
implementa? Se le pasa el login y la contraseña a un objeto intermedio
y si funciona devuelve un objeto Controlador?

Paco

unread,
Jan 14, 2008, 12:01:07 PM1/14/08
to ceac-j2ee
Reply all
Reply to author
Forward
0 new messages