Zeljko VELAJA a �crit :Je m'interroge sur ce que signifie :

>
>             prefix = prefix.intern();
>             uri = uri.intern();
>
> Qu'est-ce que �a aurait chang� si ces deux lignes avaient �t� omises ?

Extrait de la doc de String.intern()
----------------------------------------------------------------------------------

"Returns a canonical representation for the string object.
A pool of strings, initially empty, is maintained privately by the class
String.

When the intern method is invoked, if the pool already contains a string
equal to this String object as determined by the equals(Object) method, then
the string from the pool is returned. Otherwise, this String object is added
to the pool and a reference to this String object is returned."
----------------------------------------------------------------------------------

L'int�r�t est donc d'avoir une unicit� sur l'�l�ment.

Qu'est-ce que �a aurait chang� si ces deux lignes avaient �t� omises ?
Des doublons dans le Vector declarations.

J'avoue que je ne connaissais pas cette m�thode et fonctionnement de
"String".
C'�tait donc une EXCELLENTE question que tu as pos�e !

A+
Yannick.



Répondre à