| Author |
Objects as parameter inside the method.
|
Abishek Kumar
Greenhorn
Joined: Oct 27, 2007
Posts: 5
|
|
Can any one give me brief details about passing object as a parameter in the methods.
I am trying to understand the concept from books and online, but would appreciate if any one can give me just brief explanation.
For example:
public void method1(Object1 object1){
...
...
}
What is the concept behind passing object as parameter?
Thanks
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8430
|
|
|
Beginner topic. Moving.
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
Abishek Kumar wrote:
What is the concept behind passing object as parameter?
Thanks
Hi Abhishek,
Welcome to Ranch. The benefit/concept behind passing an Object as a parameter are:
Object serves as a container in which you can put many bits and pieces inside. The callers would just need to deal with one single item/argument and NOT many.You can achieve Pass By Reference.
Does that help?
|
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
No you can't. You can pass the value of a reference, but as the link you quoted says, you can't implement pass-by-reference in Java.
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
Campbell Ritchie wrote:
No you can't. You can pass the value of a reference, but as the link you quoted says, you can't implement pass-by-reference in Java.
Yes. You are right CR . I meant to say, you can achieve and NOT implement.
In a way you pass the object (reference) [Yes indeed it is 'pass by value' ], you can get the 'pass by reference' effects. Otherwise, you can't!
|
 |
 |
|
|
subject: Objects as parameter inside the method.
|
|
|