This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

OOP:Message  RSS feed

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 60075
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!