Forums Register Login

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{

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.
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.

    This thread has been viewed 980 times.

    All times above are in ranch (not your local) time.
    The current ranch time is
    Oct 18, 2018 07:16:06.