I have few basic doubts in String & its memory pool. With String s=new String("abc"); Two objects with value abc ,are created.One in prgram space referenced by s.& One goes in literal pool. 1. Is this String in literal pool remains lost or unreferenced. 2. And if program furthue uses s ,value abc comes from program space? 3. Is this literal pool is created per class? each class having 1 literal pool ---------- From SCJP K&B ,Chap6,page 420------------------
1 - I dont know... It should be dependent of the implementation... 2 - Yes 3 - If the pool was created by class, the problem of have zilions of equal Strings will not be solved, do you agree? If I have "abc" in Class1 and "abc" in Class2, and the pool is per class, i will have 2 "abc", expending more memory than i need. Strings are imutable, so, have two or more pools is not a good ideia since the String will never be changed...
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." (Fowler)
Now you have been transferred from beginners . . . Look up the String API documentation, where it says String literals are shared. I think that means there is one copy and only one of every String literal; Try this:-Try different names for the command-line argument, eg "Campbell", "Lucky", "David". Add different Strings, and repeat the test whether they are the same object (==) or identical (equals).
Go to the jakarta website and find the documentation about the bytecode engineering library, which describes how objects are put in memory in Java. See whether those suggestions sort out your problem, then report back and tell us what you found.
Joined: Oct 13, 2005
Mistake in what I posted. Please change "sh1.getEntry()" to read "sh2.getEntry()".
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com