Which inbuilt java classes other than String uses pooling? For example we have String which uses pooling,what are the other inbuit java classes that uses pooling?
2 Answers
The Integer has a pool with a pool with all the values between -128 and 127.
If you do:
Integer x = 127;
Integer y = 127;
System.out.println(x == y);
you'd get true as an output, but if you change that to:
Integer x = 128;
Integer y = 128;
System.out.println(x == y);
then you'd get false, as 128 is not part of the pool and x and y actually represent two different objects.
More info:
1 Comment
Andy Turner
Between at least -128 and 127, and you can configure the JVM to cache values outside this range too.
am not sure if it fits the bill, java.net.InetAddress uses dns resolution (domain to ip translation) cache. it actually has two caches - for positive as well as negative lookups.
1 Comment
Dave Newton
I view caching and polling as two different things.
Threadscome to mind...