This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "OOP:Message" Watch "OOP:Message" New topic


anuj thite
Ranch Hand

Joined: Apr 14, 2009
Posts: 49

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

Joined: Oct 13, 2005
Posts: 38461
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.
    subject: OOP:Message