English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I was wondering, if I have a variable, and Object1, could I do variable = Object1? Is it possible to hold an object in a variable? Thanks.

2007-03-19 16:16:29 · 6 answers · asked by Invader Z 1 in Computers & Internet Programming & Design

Sorry, I forgot to mention I'm using Java. :P

2007-03-19 16:25:50 · update #1

6 answers

That depends entirely on what language you are using.

2007-03-19 16:18:33 · answer #1 · answered by Amanda H 6 · 0 0

Provided the type of variable is either the class of Object1 or a class it extends or an interface it implements (Java is statically typed), that will work. But to pe pedantic, you're not storing the actual object in the variable, just a reference to it, since you never work with object values directly in Java.

2007-03-19 23:40:44 · answer #2 · answered by undercoloteal 3 · 0 0

You forgot to mention the language :-)
In C++ you need operator= in your class.
Do not forget that what you call "object" is also "variable"!

2007-03-19 23:21:14 · answer #3 · answered by alakit013 5 · 0 0

yes it is possible. I am in 6th grade and know that

2007-03-19 23:19:44 · answer #4 · answered by Haley 1 · 0 0

i think. soo.. why?? lol

2007-03-19 23:19:00 · answer #5 · answered by ~Emmalee~ 3 · 0 0

what?

2007-03-19 23:17:59 · answer #6 · answered by Anonymous · 0 0

fedest.com, questions and answers