- Apple iPhone 16 Pro - rutinvizsga
- iPhone topik
- Poco F7 – bajnokesélyes
- Xiaomi 15 - kicsi telefon nagy energiával
- Megérkezett a Huawei eddigi legkomolyabb futóórája
- Itt a Galaxy S26 széria: az Ultra fejlődött, a másik kettő alig
- Samsung Galaxy S24 Ultra - ha működik, ne változtass!
- Milyen okostelefont vegyek?
- Mobil flották
- Fotók, videók mobillal
Új hozzászólás Aktív témák
-
Jim-Y
veterán
válasz
SirRasor
#4228
üzenetére
Lehet hülyeséget írok, de ebben az esetben tényleg nem változtatod meg a string literál értékét, az immutable marad, ellenben a gyumolcs változó referenciáját ráállítod a string class egy objektumára ("barack"), így a gyumolcs ezentúl a barack string literálra fog mutatni a memóriában, és nem a körtére. A GC meg gondolom végzi a dolgát ezután a "körte"-n.
"Now we find that the value displayed by the myString variable has changed. We have defined immutable objects as being unable to change in value, so what is happening? Let's extend the example again to watch the myString variable closer.
String myString = new String( "old String" );
String myCache = myString;
System.out.println( "equal: " + myString.equals( myCache ) );
System.out.println( "same: " + ( myString == myCache ) );
myString = "not " + myString;
System.out.println( "equal: " + myString.equals( myCache ) );
System.out.println( "same: " + ( myString == myCache ) );
The result from executing this is:
equal: true
same: true
equal: false
same: false
What this shows is that variable myString is referencing a new instance of the String class. The contents of the object didn't change; we discarded the instance and changed our reference to a new one with new contents."
Új hozzászólás Aktív témák
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- AOC Q27G3XMN 27" 180Hz 1440p gamer monitor
- Iphone 13 mini mobiltelefon eladó
- Ryzen 5 5500 (ÚJ, 2 ÉV GARI) - 16 GB DDR4 3200 MT/s CL16 - 1 TB NVMe SSD (G4) - MSI MAG Vampiric ház
- Samsung NP270E5E-K07PL Notebook 3 órás akkuval
- Új Gamer PC - Ryzen 7 5700X / RTX 5060 Ti / B550M WIFI / 16GB RAM / 1TB SSD / 650W
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest

