Best Regards,
Ved.
SCJP 1.6 96%
Best Regards,
Ved.
SCJP 1.6 96%
Best Regards,
Ved.
SCJP6.0,My blog Ranchers from Delhi
Shanky Sohar wrote:Hey ,but i studied that String is also an object
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
SCJP6.0,My blog Ranchers from Delhi
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
OCPJP 6.0 93%
OCPJWCD 5.0 98%
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Bert Bates wrote:
on the real exam String objects are never used in GC questions
OCPJP6
SCJP 1.6 96%
Trivikram Kamat wrote:
But just out of curiosity, if Line 12 is replaced by:
will there be two objects available for GC after the method returns?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
OCPJP6
SCJP6 Study Guide wrote:
String s = new String("abc"); // creates two objects,
// and one reference variable
In this case, because we used the new keyword, Java will create a new String object in normal (nonpool) memory, and s will refer to it. In addition, the literal "abc" will be placed in the pool.
OCPJP6
The objects created in the String pool are not subjected to GC until the class is unloaded by the JVM. They get discarded at that time or just before the virtual machine unloads the class' bytecode.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
OCPJP6
OCPJP6
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:
Then, there will be 3 objects totally. One is in the String Constant Pool and other two are in the heap.
OCPJP6
Trivikram Kamat wrote:
The one on the String constant pool ("Javaranch") is a literal, and not an object right?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:
I think, in Java, other than primitives, all are O(o)bjects. So, that's also an object!
OCPJP6
Trivikram Kamat wrote:
In Oracle Java SE tutorials website, literals is explained under Primitive Data Types.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|