This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Sure, you can pass arrays. You can pass an array of objects or primitives, as long as the type matches the method signature (and the method knows what to do with it). For example, some method signatures:
In that last example (bar), you can legally pass any array since all arrays are Objects.
For your second question, the answer depends on how you want to look at it. Some say that Objects in Java are passed by reference, and primitives (int, float, etc) are passed by value. Others like to think that everything is passed by value, because what is really happening "in the guts of the JVM", is that you are passing the object reference by value. Passing the object reference by value is like passing the object itself by reference. In one sense, they are both right, as they both end up with the right behavior. It just depends on how you think about things. One of them will make more sense to you and help you to remember what is happening - that's probably the one you should use.
Joined: Aug 03, 2002
thx very much~~ I begin to like this community : > cheers