• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Object Communication

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when objects communicate by passing messages , the message is sent my a method call.

class Message
{

static void call(int i)
{
System.out.println(i);
}

public static void main(String args[])
{
call(10);
}
}

how does parameter in the method call, provide exchange of information between the
caller object and callee object. which is the caller object and callee object.
there is no object instantiation what aobjects are this. Is method invoked on the object or the object is invoked on the method.please help, thanks.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prashant,
In this eg, since u r communicating between static methods, u wouldn't need an object (i.e. an instance of a class) to do the job. Static methods/variables are class level - meaning a single copy of these variables exists for the class rather than for every instance of the class.
The parameter's major role beside carrying the requisite information to the method, is also to help in choosing the appropriate method in case of method overloading.
An object invokes a method - not the other way around. A method is called by an object. There is nothing like a caller object and a callee object in your eg, - since ur calling a static method(call) from another static method(main) within the same class, u can call the method directly.
eskay !
 
Hug your destiny! And hug this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic