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

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. 22nd, 2025 03:15 pm
Powered by Dreamwidth Studios