string-pool Questions
3
Solved
Is there any performance benefit by using a private final static String in java vs using a local string variable that has to get "initialized" every time the method is accessed?
I do think that us...
Chicago asked 23/3, 2016 at 18:5
1
Solved
I am learning about reflection in Java. By accident, I discovered the following, for me unexpected behavior.
Both tests as written below succeed.
class NewInstanceUsingReflection {
@Test
void tes...
Sixtieth asked 8/9, 2022 at 20:39
5
Solved
My Question is what's the use of creating string object in string pool as well as on Heap when we declare String as String a = new String("abc"); What is the advantage ?
And why not we create stri...
Dejadeject asked 21/11, 2014 at 6:10
2
Solved
Beware: I'm not trying to compare if the characters are equals. Because I know how to use the String.equals() method. This question is about String reference
I was studying for the OCA exam when I...
Operant asked 18/5, 2017 at 2:17
7
Solved
I was asked in an interview about the number of objects that will be created on the given problem:
String str1 = "First";
String str2 = "Second";
String str3 = "Third";
String str4 = str1 + str2 +...
Simsar asked 23/8, 2019 at 17:48
1
Solved
Below is the Javadoc comment for String.intern() method:
*Returns a canonical representation for the string object.
A pool of strings, initially empty, is maintained privately by the class Stri...
Tatia asked 24/4, 2018 at 11:19
7
Solved
Consider this code:
String first = "abc";
String second = new String("abc");
When using the new keyword, Java will create the abc String again right?
Will this be stored on the regular he...
Thong asked 10/12, 2009 at 15:51
1
Solved
After seeing this question and its duplicate a question still remained for me.
I get what is and == do and why if I run
a = "ab"
b = "ab"
a == b
I get True. The question here would be WH...
Gaillardia asked 21/2, 2017 at 9:55
7
Solved
If jvm creates string pool for memory optimization, then why it creates new Object each time we create string using new keyword even though it exists in string pool?
Snip asked 23/9, 2015 at 7:11
7
Solved
Java string pool coupled with reflection can produce some unimaginable result in Java:
import java.lang.reflect.Field;
class MessingWithString {
public static void main (String[] args) {
...
Kleenex asked 17/9, 2015 at 6:29
2
Solved
I understood that if a String is initialized with a literal then it is allotted a space in String Pool and if initialized with the new Keyword it create a String's object. But I am confused with a ...
Trustless asked 14/9, 2015 at 12:2
1
Solved
What will happen if there are many String literals on String Pool and it runs out of memory. Does it grow its size, if yes how? If not, what will happen if i try to create more String literals?
Di asked 18/6, 2015 at 9:39
2
Solved
I am preparing for the OCA SE 7 exam, and some of these questions are really (!) tricky.
In one of the books Im using I found an error I think, so I would like to confirm the following please...
...
Hawse asked 26/2, 2015 at 20:49
1
Is there any way to check, currently which Strings are there in the String pool.
Can I programmatically list all Strings exist in pool?
or
Any IDE already have this kind of plugins ?
Wayless asked 5/6, 2014 at 6:57
3
Solved
I need a "string pool" object into which I can repeatedly insert a "sequence of chars" (I use this phrase to mean "string" without confusing it with std::string or a C string), obtain a pointer to ...
Guffey asked 5/1, 2014 at 20:0
2
Solved
I've just been inspecting the following in gdb:
char *a[] = {"one","two","three","four"};
char *b[] = {"one","two","three",&quo...
Authentic asked 9/7, 2012 at 16:56
1
© 2022 - 2024 — McMap. All rights reserved.