Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Programmer Certification (OCPJP)
stack or heap?
Andre Enimot
Ranch Hand
Posts: 31
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
K&B book 6, p.184-185, Fig 3-1
class Collar { } class Dog { Collar c; // instance variable String name; // instance variable public static void main(String [] args) { Dog d; // local variable: d d = new Dog(); d.go(d); } void go(Dog dog) { // local variable: dog c = new Collar(); dog.setName("Aiko"); } void setName(String dogName) { // local var: dogName name = dogName; // do more stuff } }
Is the
string
literal "Aiko" in line 12 created on the stack in the string literals pool, or on the heap as a new object, as shown in Fig 3-2?
Rajkamal Pillai
Ranch Hand
Posts: 479
1
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
String would get an entry in the pool but the whole Object would be created in the pool? Could anyone correct me if I'm mistaken?
Neha Daga
Ranch Hand
Posts: 504
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
read
this
SCJP 1.6 96%
Andre Enimot
Ranch Hand
Posts: 31
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks, clear now.
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
about serialization
EL Execution Problem
c:set problem
Serialization: Non serialized class issue
how to accept an instance of a class as a parameter
More...