lomeo: (гомер)
[personal profile] lomeo
Только вчера с удивлением обнаружил, что стринговый кэш в java всё таки работает:


public class Test
{
    public static final void main(String[] args)
        throws Exception
    {
        String test1    = "this is a text";
        String subTest1 = test1.substring(10);

        String test2    = "this is not a text";
        String subTest2 = test2.substring(14);

        System.out.println(subTest1 == subTest2);
        System.out.println(subTest1.intern() == subTest2.intern());
    }
}


вернёт

false
true

Date: 2006-07-13 10:07 am (UTC)
From: [identity profile] wiwi.livejournal.com
почему с удивлением?
я думал он всегда и работал...

Date: 2006-07-13 10:18 am (UTC)
From: [identity profile] lomeo.livejournal.com
я не знал

Profile

lomeo: (Default)
Dmitry Antonyuk

April 2024

S M T W T F S
 123456
7891011 1213
14151617181920
21222324252627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 13th, 2025 09:21 am
Powered by Dreamwidth Studios