This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Succeeding with AI and have Veljko Krunic on-line!
See this thread for details.
Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

References variables

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning! (I'm in Switzerland :-))

This morning I'm confused about the book of Kathy&Bert...

In the self exam for the 3rd chapter on the 10th question it say's in answer:

References variables can live on the stack or on the heap and I believed that references variables lived only on the heap... Not?

Thanks for help... And sorry for my bad english

Valentin Jacquemin
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bonjour,

Est-ce que tu peut envoyer le question entier? J'ai du mal a comprendre le question.

>References variables can live on the stack or on the heap and I believed >that references variables lived only on the heap... Not?

Last night I did some of chapter two in the same book. She mentioned that with method local reference variables, the OBJECT lives on the heap but the REFERENCE always exists on the stack. Maybe that's what she means, although I can't say for sure.

Moi, je suis a Paris. Ca fait du bien de parler en angalais et francais en meme temps

Anyways, if you send the entire question I think you'll find the correct solution.

have a nice day

Graham
 
Valentin Jacquemin
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great!!!

R�ponse de la question 10 du chapitre 3:
When an object has a reference variable, the reference variable lives inside the object, on the heap.

Et la donn�e qui est dite comme correcte:
Some reference variables live on the stack, and some live on the heap.

Je croyais que tous les objets �taient dans le heap! Et c'est pas ce que dit la donn�e non?

I believed that references variables lived only on the heap

Merci c'est cool de pouvoir parler francais!
 
Valentin Jacquemin
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody could help me ?
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reference variables can both live on the stack an on the heap. When you instantiate an object in a method, reference variable lives on the stack, but the object itself can have references to other ojects and then these references live on the heap.
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bonjour,

je pense que c'est meilleur de parler en anglais parce que plus de ranchers comprend ca. En plus, je crois que l'examen sera en anglais...

The variables local to a method live on the stack, while object variables (ie. fields of the object) are stored together with the object, which is on the heap. In both cases, you can have reference variables, so reference variables can both be stored on the stack and on the heap.

Regards,
Tilo
 
Valentin Jacquemin
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Aleksander Zielinski:
Reference variables can both live on the stack an on the heap. When you instantiate an object in a method, reference variable lives on the stack, but the object itself can have references to other ojects and then these references live on the heap.



Thanks a lot!!

Powa Javaranch!

Have a nice day, Valentin Jacquemin
 
    Bookmark Topic Watch Topic
  • New Topic