Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes If objects can't be passed.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "If objects can Watch "If objects can New topic
Author

If objects can't be passed....

Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11


I'm using the books "HeadFirst Java (2e)", and Horstmann's "Big Java"

If what I'm reading/understanding is true that objects can't be passed to other classes -- only values can be passed....
then how can you manipulate an object instance in more than one class?

NOW I'M REALLY CONFUSED.

--Janeice


When you do things right, people won't be sure you've done anything at all.
Miklos Szeles
Ranch Hand

Joined: Oct 21, 2008
Posts: 142
Hi Janeice,

Java passes primitive types by value and instead of passing objects java passes the references to the objects(which are values). If it's not clear please copy the explanation here, so we can help to clarify things.
Here's an explanation what I found using search:
http://www.javaranch.com/campfire/StoryPassBy.jsp
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
http://faq.javaranch.com/java/CallByReferenceVsCallByValue should help as well..
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Miklos Szeles wrote:Hi Janeice,

Java passes primitive types by value and instead of passing objects java passes the references to the objects(which are values). If it's not clear please copy the explanation here, so we can help to clarify things.
Here's an explanation what I found using search:
http://www.javaranch.com/campfire/StoryPassBy.jsp


Yep, that's pretty much the way like to explain it. Also I suppose that in the current context you could consider a reference as being something like a pointer to an object.

As an aside, IMO the way in which java deals with objects and method calls is not particularly difficult to understand. Where I do see a lot of problems is in a misunderstanding of the exact meaning of the words "Pass by Reference" as opposed to "Pass a Reference". I understood the way it actually worked long ago, but the first time someone said "There is no such thing as pass by reference in Java", without properly explaining what "pass by reference" means, it only created confusion.

Anyways my little commentary does not apply directly to the original question, so Janeice if my remarks don't seem clear, don't sweat it, just remember them the next time somone uses the phrases "pass by reference" and/or "pass a reference".
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11

So lemme get this straight....

there's no way to pass the entire "remote controller" to another class. Only parts of it (like its instance variables and the values its methods return).

I dunno why I can't get this concept right.....

/Janeice

Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Janeice DelVecchio wrote:So lemme get this straight....

there's no way to pass the entire "remote controller" to another class. Only parts of it (like its instance variables and the values its methods return).

I dunno why I can't get this concept right.....

/Janeice



Not quite correct. Another way of looking at it is what you pass to a method is a way to refer to the object. In essense, by specifying the parameter in the declaration of the method, you are saying to the method "use this name to refer to the object". Does that help?
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11

Fred - I like your chess game.

I'm still unclear.... let's see if I can ask differently....
If I create an object.... and do something to it.....



there's no way to send that dog (with the cookie he's now eaten) to another Class:



....right? I would have to send like this:



or is it all the same?
--Janeice
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

No. You are not restricted like that.

But as has been pointed out, you don't really send the object itself, you send a reference to that object. It's really a fine point, but you seem to have it in your mind that somehow the instance can't be made available to other class' methods, and you need to just let go of that notion.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
You can pass the Dog details and get the last Cookie details like that. But I still think the HandBittenException is more likely if you try to retrieve a cookie from the dog
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Janeice, try this.

Say an object is referenced in a method call. If it really was the case that the object itself is passed to the method, then it would have to be passed back, wouldn't you say? But that does not happen.

The called method can make a change to the object and that change also affects the calling method. When control is returned to the calling method, it will see that change. And there is no requirement that the called method return the object itself to the calling method.

Anyways, all you really have to understand is that when an object is in a method call, there is only ever one copy of the object. And you don't have to pass it back. That will allow you to move ahead with your studies. Proper understanding of what goes on behind the scene will come in due time.

Fred.

p.s. thanks for the remark on the program. It's a hobby in and of itself, it's been a long time coming and a long way to go.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11

Ok I think we're getting somewhere..... thanks a lot....

as an additional question....

How do the other methods in the other classes know which dog they are giving the cookie to? I mean, if there's 10 dogs on the heap, how does it know to give the cookie to fido and not snippy or misty?

What's more..... how does it know that ANY dogs exist at all??

Do they get declared locally in those classes?

--Janeice
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Janeice DelVecchio wrote:Ok I think we're getting somewhere..... thanks a lot....

as an additional question....

How do the other methods in the other classes know which dog they are giving the cookie to? I mean, if there's 10 dogs on the heap, how does it know to give the cookie to fido and not snippy or misty?

What's more..... how does it know that ANY dogs exist at all??

Do they get declared locally in those classes?

--Janeice



Each instance of the Home class gets a Dog reference automatically. This is determined by line 3 of Campbells Home class.

But the Home known as newHome doesn't get an actual dog until line 08 of Campbell's 3rd section of code gets exectuted, this is a call to newHome's setDog() method. Whan that happens, the dog know as fido becomes known to the people in newHome as d. In other words, the name gets a dog.

Whoever lives in Campbell's third block of code knows still knows the dog as fido. It the same dog, it just has two names.

hey, that was fun! Thanks Campbell


p.s. because I can't see the Home contructor in Campbell's example, it seems to have been left out, I can't really be sure that the house doesn't already have a dog. It is possible that the House constructor creates a dog d. In which case the call to newHome.setDog(fido) means that fido takes another dog's place.

p.s. see my bolded phrase. To be precise, it should read "creates a dog to be given the name d. The name already existed because of line 03 of the Home class.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11

Uhmmmm..... maybe making progress...... maybe more confused......

So if the second block of code were to turn the dog (d) purple, the dog in the third block of code (fido) would be purple too?

Why doesn't the dog (fido) need to be labeled static for that to happen?

/Janeice/
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Janeice DelVecchio wrote:Uhmmmm..... maybe making progress...... maybe more confused......

So if the second block of code were to turn the dog (d) purple, the dog in the third block of code (fido) would be purple too?

Why doesn't the dog (fido) need to be labeled static for that to happen?

/Janeice/


The answer to your first question is yes. In the 2nd block of code the dog is called d. In the third block of code, the dog is called fido. But it is the same dog. There is only one dog to be seen. Two names. One dog.

I am not sure how to answer your second question. I can tell you that if line three of the second block of code read

static Dog d = new Dog(...); that would mean that every Home would have the same Dog, and I don't think we want that.

Thing is, as far as I can see, I don't have enough information about the third block of code to be sure. But it is probably not part of a Home. I don't have the Head first Java book, so I can't say for sure, all I can say is that static in block 3 isn't required given the information in this thread. Maybe Campbell can explain that one.


hmm this is not the easiest of examples. It kind of depends how you interpret what is happening here. A real dog cannot exist in two different places at once. Is the dog actually given to the new home? This is an abstract model that loses something in the interpretation. Suppose that once the dog is known to newHome as d, then the name fido can be assigned to a different dog, then the first dog will only be known in newHome, by the name d. In that sense, the third bloack of code might be an animal adoption service.

IMO, consider a different example with which to learn the concepts of an object, there are lots of them out there. Don't sweat too long over this one.

http://java.sun.com/docs/books/tutorial/java/concepts/index.html
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11

So what happens if you have more than one dog?

If you:



which dog does the "Dog d" "remote controller" (in the 2nd block of code) point to? All of them? The last one?

If it's all of them, how do you tell the difference? If it's only the last one..... well...... what if you needed more than one dog?

Thanks SO much for all your help!!
-Janeice
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Janeice DelVecchio wrote:So what happens if you have more than one dog?

If you:



which dog does the "Dog d" "remote controller" (in the 2nd block of code) point to? All of them? The last one?

If it's all of them, how do you tell the difference? If it's only the last one..... well...... what if you needed more than one dog?

Thanks SO much for all your help!!
-Janeice


If this is in the 3rd block of code, then after it is over, the name d in newHome will refer to the dog known as fluffy. Unless fido and spunky were given new names by the people in newHome, they would cease to exists to the newHome, but they might still be known in the third bloack of code, which we can call a dog adoption agency.

please note my last comment in the previous post. there are complications here. Don't worry about the possibility of the same dog existing in two different places for a while.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11

I guess I'm less concerned about the real life implications of the example and more concerned with the logistics.....

How (or where) do you create more than one of the same object on this "heap"?

We talked about making more than one "remote control" for the same object (fido and d)... and how if you send more than one object to the same method, the last one is the only one that keeps the reference (fluffy)... and the other guys lose their second remote.

But how about if you needed that method to have a "remote control" for more than one of the same object? Can you create as many "remote controls" for the same object as you want?

static Dog d = new Dog(...); that would mean that every Home would have the same Dog, and I don't think we want that.

.... that made sense (probably the most sense of everything!!). I like to see things in real life terms.... that's why I like this HeadFirst book. I'm just having a hard time with this concept.

I'm really sorry for being such a pain about this, but this is the most understanding I've gotten out of this. You are being REALLY helpful!

Thanks again.... so much!
-Janeice

Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Janeice DelVecchio wrote:I guess I'm less concerned about the real life implications of the example and more concerned with the logistics.....

How (or where) do you create more than one of the same object on this "heap"?



that I can't answer. or maybe I can see below.

Janeice DelVecchio wrote:
We talked about making more than one "remote control" for the same object (fido and d)... and how if you send more than one object to the same method, the last one is the only one that keeps the reference (fluffy)... and the other guys lose their second remote.


OK, i think. It is only the last dog that keeps the reference d, in newHome. For all we know, all three dogs are still known as fido, spot(?), and fluffy, at the adoption agency. The reason why only fluffy keeps the 2nd name d, is because you can't have one name referring to three dogs. A reference variable can only point to one object. All indicatins are that only the dog known as fluffy at the adoption agency is still known in newHome.

Janeice DelVecchio wrote:
But how about if you needed that method to have a "remote control" for more than one of the same object? Can you create as many "remote controls" for the same object as you want?


hmm an object is unique. There isn't more than one of the same object. It maybe that the same set of data on the heap is used by both objects, for immutable objects such as strings, I don't know, but for yor purpose as a programmer, I don't think that changes the way you do things, unless your dogs start breeding like rabbits and use up all your RAM. (Remote Animal Memory)

Am I clear on that last point? The word immutable is relevant here. Strings are immutable objects, I think the Dog cannot be immutable because of the instance variable cookie, which may be eaten. So I son't think two dogs can share the same heap space.


Janeice DelVecchio wrote:
I'm really sorry for being such a pain about this, but this is the most understanding I've gotten out of this. You are being REALLY helpful!

Thanks again.... so much!
-Janeice



no problem, I am having fun with this dog stuff. and it forces me to think about my own undersatnding, which is good.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Janeice:

How (or where) do you create more than one of the same object on this "heap"?


Objects are created on the heap when you call the constructor via the new keyword. For example, if I do this:

I've created three new objects (of class Object ) on the heap. I have a reference to each one (obj1, obj2, obj3). The JVM knows which object is pointed to by each reference. If, later on, I do this:

I still have three objects on the heap (for the moment at least). However, now my three references point to the same object. The other two objects, since they are no longer referenced, will by marked by the JVM for garbage collection.

But how about if you needed that method to have a "remote control" for more than one of the same object? Can you create as many "remote controls" for the same object as you want?


These are both possible. In the first instance, you could create a List of objects, and pass that List to the method, which would work on each object in the List. In the second, my second code example demonstrates just that. The object that the references point to will stay on the heap until the last reference goes out of scope, after which it will be marked for garbage collection and eventual deletion.

Hope that helps.

John.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
John de Michele wrote:
But how about if you needed that method to have a "remote control" for more than one of the same object? Can you create as many "remote controls" for the same object as you want?


These are both possible. In the first instance, you could create a List of objects, and pass that List to the method, which would work on each object in the List. In the second, my second code example demonstrates just that. The object that the references point to will stay on the heap until the last reference goes out of scope, after which it will be marked for garbage collection and eventual deletion.

Hope that helps.

John.


I'm a little unclear on this "more than one of the same object" thing. How is a List of objects more than one of the same object?
regards.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
You cannot have the same object twice. You can have two identical objects however.. . . but you can have two names for the same object
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Campbell Ritchie wrote:You cannot have the same object twice. You can have two identical objects however.[code]


yeah, that's the way i see it too. I guess my original interpretation was that by saying "more than one of the same object" Jaenice was talking about two objects sharing the same heap space, as in the case of identical strings, hence my remarks about the immutability or lack thereof of dogs. I guess I was just commenting on the difference in the way Mr. de Michele and I interpreted the original question.

Anyways, I guess we'll wait to see what Janice actually meant.

regards.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
I guess I was just commenting on the difference in the way Mr. de Michele and I interpreted the original question.


Fred:

I interpreted what Janeice was saying to be 'more than one object of the same type'. It seems to me that Janeice is having some difficulty with the idea of object references and how they work. I could be entirely wrong, though .

John.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
John de Michele wrote:
I guess I was just commenting on the difference in the way Mr. de Michele and I interpreted the original question.


Fred:

I interpreted what Janeice was saying to be 'more than one object of the same type'. It seems to me that Janeice is having some difficulty with the idea of object references and how they work. I could be entirely wrong, though .

John.


Yes, that's what I figured. Also, I agree with you, a misunderstanding about how "objects are passed", and I use that phrase loosely, is likely rooted in a misunderstanding of object references themselves.

It might be helpful at this point to make a comparison to primitives, such as int and double. With primitives, there is no reference, the variable contains not a reference to the data, but the data itself. Therefore, when a primitive is passed to a method, you are passing a copy of the data itself, not a copy of the a reference. That is why when a method changes the primitive data, the original primitive remains unchanged.

If one is wondering why things are done this way, well I suppose one reason is that you always know in advance how much memory a primitive data type will use, the same can't be said about objects.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Fred Hamilton wrote:If one is wondering why things are done this way . . .
Probably also for performance; it is much faster to do arithmetic with primitives than with boxed Objects.

And I always suspect there is a lot of "because they used to do it like that in C++ and C" to many of these mysterious questions too.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11

I think I'm really getting this now!!

When I looked at the pictures again, earlier in this thread, with the clouds and the remote controls in the class section of the HF book and in the campfire section of this site, it started making sense enough to realize I had no idea what it was talking about.

Sometimes, you need to figure out what you don't know in order to ask the right questions. You folks have been so helpful.

I've been at this for 3 weeks now.... typing "Rectangle r1 = new Rectangle(10,10,5,7)" -- and manipulating the rectangle.... and not really realizing what I'm doing. Now I get it. There's a new space on the heap for a rectangle object. It's coordinates start at (10,10) and it's 5 units wide and 7 units high. "r" is NOT the name of the rectangle. "r" is just the remote I use to access its values and properties from where I am. The compiler and JVM don't care that the object has a name except when you make the object reference. You can easily take it away... "r1 = new someOtherRectangle()"..... and now there's 2 rectangles on the heap, and no way to control/access the original rectangle.

I guess there's some things you don't have to know to be able to just make something work. The school text basically said "you probably will use the terms object and object reference interchangeably." Doing that caused all this confusion. I probably will be able to AFTER I get the hang of this, but I think that's the source of the issue.

I think the important concept here is how "object references" LOOK like variables and you can do more with them.... but ultimately they're not variables. They are not the ones that know or do anything. They need to ask the object they refer to. For all the reference knows, someone with another "remote control" for that object might have turned its dog purple while it wasn't looking.

Thanks so much.... I'll refer to this thread for a long time!
--Janeice
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11


.... and by the way......

John de Michele wrote:
I guess I was just commenting on the difference in the way Mr. de Michele and I interpreted the original question.


Fred:

I interpreted what Janeice was saying to be 'more than one object of the same type'. It seems to me that Janeice is having some difficulty with the idea of object references and how they work. I could be entirely wrong, though .

John.


This was correct. I wanted to know how to make more than one "object of the same type" (not knowing I was doing that already).

Thanks again!
Janeice
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Janeice DelVecchio wrote:
.... and by the way......

John de Michele wrote:
I guess I was just commenting on the difference in the way Mr. de Michele and I interpreted the original question.


Fred:

I interpreted what Janeice was saying to be 'more than one object of the same type'. It seems to me that Janeice is having some difficulty with the idea of object references and how they work. I could be entirely wrong, though .

John.


This was correct. I wanted to know how to make more than one "object of the same type" (not knowing I was doing that already).

Thanks again!
Janeice


Cool, in that case, just ignore my comments above about the immutability of dogs, and sharing heap space. It's not relevant to this thread.

p.s. I read your post that started with "I think I am getting this now", and yes, it does indeed look that way. Keep in mind wen you are dealing with others that people have their own way of describing and understanding things, and even when they have it right, differences in the way they describe things can sometimes lead to misunderstanding and confusion.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Janeice DelVecchio wrote:I think I'm really getting this now!!
And that makes it all worth while
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Janeice DelVecchio wrote:

I've been at this for 3 weeks now.... typing "Rectangle r1 = new Rectangle(10,10,5,7)" -- and manipulating the rectangle.... and not really realizing what I'm doing. Now I get it. There's a new space on the heap for a rectangle object. It's coordinates start at (10,10) and it's 5 units wide and 7 units high. "r" is NOT the name of the rectangle. "r" is just the remote I use to access its values and properties from where I am. The compiler and JVM don't care that the object has a name except when you make the object reference. You can easily take it away... "r1 = new someOtherRectangle()"..... and now there's 2 rectangles on the heap, and no way to control/access the original rectangle.



keep in mind that:



will not compile, unless we're using polymorphism here.

Jose
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11

Really, Jose?

Really?

I think if you're telling me my conversational code won't compile you're missing the point of what I was saying.... and thus the point of the entire thread. The point was to illustrate that the reference to the object could be taken away, leaving the original object with no references (and ultimately garbage). It doesn't matter about actually compiling because it was a make-believe reference to a make-believe rectangle.

Take it easy, I'm a n00b. Polymorphism will be another day, and another thread.
Regards,
Janeice
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
So you're using conversational 'code', to refer to a learning problem by including java and/or C/C++ like code in it ? I guess you can qualify that as pseudo-code. Whether it's pseudo-code or conversational code, the fact remains that, what you wrote for that pair of assignments it's semantically incorrect independent of the type of high-level language you're using, because you're using one reference variable to refer to Objects of different types; and was remarking it because I'd say letting it unrevised would confuse you further.


Janeice DelVecchio wrote:
Really, Jose?

Really?


A sarcastic reply is rude, and therefore should be unacceptable coming from a student asking for help.

Jose

Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1659
    
  11

So you're using conversational 'code', to refer to a learning problem by including java and/or C/C++ like code in it ? I guess you can qualify that as pseudo-code. Whether it's pseudo-code or conversational code, the fact remains that, what you wrote for that pair of assignments it's semantically incorrect independent of the type of high-level language you're using, because you're using one reference variable to refer to Objects of different types; and was remarking it because I'd say letting it unrevised would confuse you further


I actually thought you were confusing matters more.


A sarcastic reply is rude, and therefore should be unacceptable coming from a student asking for help.



I took your first reply as an attack on semantics. We had twenty-some-odd posts here before you came along and I learned a lot. The purpose of the thread was not to see if anything would compile.... actually it's about learning the conceptual difference between objects and object references. We discussed giving references, taking them away, and objects having multiple references. Picking apart my sentence about taking away an object reference is far from helpful.

My rectangles may have been semantically incorrect -- you're right. You got to show off your knowledge and pick apart my learning. Great. But remember.... you missed the point of the entire thread.

Sometimes you need to decide whether being right is worth putting someone down.
/Janeice/
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Jose Campana wrote: . . . A sarcastic reply is rude . . .
Take it easy, Jose Campana. I don't detect any sarcasm there.

And Janeice DelVecchio, please . . . "A soft answer turneth away wrath" (Pr 15:1)

Both of you, take it easy please.
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Just to clarify things,

I have never ever tried to put anyone down. I'm only trying to help, the same as they did to me in the past, and I'm grateful for.

Sarcastic Reply or not, it was an Aggresive Reply nonetheless.

Jose.

PD. Sorry If I offended anyone; it is not, and has never been my intention.

Best Regards.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Apologies accepted
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Campbell Ritchie wrote:"A soft answer turneth away wrath" (Pr 15:1)

Campbell, you have just given a new definition to quote your sources


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Maneesh Godbole wrote:
Campbell Ritchie wrote:(Pr 15:1)
And there was the source. AV, of course.
Dan Walin
Ranch Hand

Joined: Nov 11, 2003
Posts: 109
Janeice wrote:
I guess there's some things you don't have to know to be able to just make something work.

This quote from Janeice is so true and worth remembering when learning something new (Java in this case). When I was beginning, I would find code and copy it and it would work and I would think "this is easy". . . until something goes wrong and it does not work and you have no idea why. When I work with others who are beginning, I see them being impatient, wanting to just "get it to work" like I have been and I try remind them that they have to really understand what they are doing, otherwise they are just building something that they won't be able to support when (not if) there are problems.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Dan Walin wrote:
Janeice wrote: I guess there's some things you don't have to know to be able to just make something work.

This quote from Janeice is so true and worth remembering when learning something new (Java in this case). When I was beginning, I would find code and copy it and it would work and I would think "this is easy". . . until something goes wrong and it does not work and you have no idea why. When I work with others who are beginning, I see them being impatient, wanting to just "get it to work" like I have been and I try remind them that they have to really understand what they are doing, otherwise they are just building something that they won't be able to support when (not if) there are problems.


sure, but I don't necessarily see a problem in being shown a method that works. It depends how you use the information, I think with java you can learn a lot about the way things work by looking at something that works. It depends what stage you are at. If you know something about the Java Class Heirarchy, then being given something that works is an efficient way to learn. Of course if you don't take the trouble to learn why what you have works, then I agree with you, you aren't learning much.

That being said, if you don't have that underlying conceptual understanding of inheritance and the class heirarchy, then probably my remarks aren't too useful.
 
 
subject: If objects can't be passed....
 
Similar Threads
Passed
Passed ?
Passed SCJP 6 with 91%!
Passed
Passed