my dog learned polymorphism*
The moose likes Beginning Java and the fly likes OOP:Message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "OOP:Message" Watch "OOP:Message" New topic
Author

OOP:Message

anuj thite
Ranch Hand

Joined: Apr 14, 2009
Posts: 49
Hi,

I am new to oop.

i am confuse between sending message and a function call.

can anybody tell me is there any difference or are they same ???

i know in oops that we can communicate through any object by sending a message.

i am giving one example :

Class A{
A(){}

add(int i){
-----
----
}

public static void main(){
// is it sending a message to an object A
new A().add(3);
}
}

if it is a message passing, then what do you mean by a function call ???


Thanks in advance.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
Welcome to JavaRanch

That is too large a question to answer quickly; you will have to write lots of object-oriented programming , and see whether you can find a book or internet tutorial which is any good. There are some very good websites where people will help with your questions about OO programming, for example this one

We don't say "function call" in Java; we call those things "methods" so that is a "method call" or "method invocation".

In the example you quote,
  • Yes, you are creating an object of the class "A".
  • Yes, you are sending a message, telling it to use its add method with the value 3.
  • You are not specifying any initial values for anything in the A object, because you have empty () after "new A".
  • But you can never use the A object; after that statement, the "A" object will vanish into cyber-limbo never to be see again. Now if you gave an identifier (name) to the "A" object, you could write thisI hope that is of help

    By the way: Please use the code button, and maintain indentation in your code; it is much easier to read.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: OOP:Message
     
    Similar Threads
    serialization
    Will a started thread run to completion in this example?
    Handler and Progress
    add an empty row to the Jtable
    Command Object in MultiActionController