Je to tak, nevytvara novy onjekt, pokial uz dany retazec existuje v pamati.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of "Ing. Jan Novotný" Sent: Thursday, September 28, 2006 12:09 PM To: Java Subject: Re: java.lang.String.intern() Nejsem si jistý, ale nezajistí se touto metodou, že konkrétní string bude na haldě pouze jednou? Tzn. že je teoreticky možné toto: String a = "ahoj"; String b = "ahoj"; if (a != b) System.out.println("a different from b"); //mohlo by se vypsat a.intern(); b.intern(); if (a == b) System.out.println("a same as b"); //musí se vypsat Nejsem si tím jistý, ale myslím, že takhle to funguje ... equals samozřejmě vrátí v obou případech true (imlementace equals u stringu myslím interně to intern právě volá). Honza Kamzik-II napsal(a): > Zdravim diskuzi, mam opet jeden zacatecnicky dotaz :) > Tentokrat by me zajimalo, jake vyuziti ma metoda intern () > tridy java.lang.String, zaujalo me tohle: > > String helloWorld = "HelloWorld"; > String hello = "Hello"; > String world = "World"; > > helloWorld == ( hello + world ).intern (); > > mohl by mi nekdo vysvetlit k cemu je tato > metoda dobra? :) -------------------------------------------------------- Pravni informace: Tento e-mail a jakekoli soubory k nemu pripojene mohou byt duverne, utajovane, pripadne chranene pravnimi predpisy. Pokud nejste osobou, ktere je tato zprava urcena, pripadne osobou poverenou k jejimu doruceni, davame vam timto najevo, ze jeji sireni jakoukoli formou nebo zverejneni teto zpravy je prisne zakazáno. Pokud jste tuto zpravu jakymkoli zpusobem obdrzeli, prosime oznamte toto odesilateli bez zbytecneho odkladu a pote ji vymazte z Vaseho systemu. Legal Disclaimer: The information contained in this message and any attached files can be confidential and may be legally privileged. If you are not an intended recipient of this message or an agent responsible for delivering this message, you are informed by this that any distribution or other dissemination is strictly prohibited. If you have received this message by mistake please let the sender know immediately and then delete this mail.
