Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2008

Tip: Looking for answers? Try searching our database.

Can a class accept a message?

Thread view: 
tenxian - 29 Apr 2008 01:22 GMT
I want a confirmation.
Daniel Pitts - 29 Apr 2008 01:28 GMT
> I want a confirmation.
That is a very vague question. So the answer is Yes.

public class Message {
}

public class MessageAcceptor {
  public static void accept(Message message) {
   System.out.println("I accept the message " + message);
  }
}

So, what are you really asking?

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Mark Space - 29 Apr 2008 02:12 GMT
> I want a confirmation.

This kind of statement comes across as bit rude.  Please use a less
demanding tone.

In Java, classes can accept messages, for reasonable definitions of the
word "message".

    String.getClass().getName();

sends the message "getName" to the class object for String.  One could
also call static methods a message that a class will accept.

Normally however, it's an object that takes the message.

    String s = "Hello World\n";
    s = s.trim();

sends the message "trim" to the String object "s".

(In object oriented design that I'm familiar with, a "message" is
normally implemented with a method.  Other forms of dispatch might
exist, although I can't think of any off the top of my head.)
Roedy Green - 29 Apr 2008 02:21 GMT
On Mon, 28 Apr 2008 17:22:50 -0700 (PDT), tenxian
<hi.steven.tu@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>I want a confirmation.

I presume you mean this is the Smalltalk sense.

Of course.  All it means is can your execute a method on an object
with parameters.
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.