Re: Can a class accept a message?



tenxian wrote:
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.)

.



Relevant Pages

  • Translating some Java to Python
    ... A while ago I wrote a class in Java for all kinds of dice rolling ... The Java version has static methods for common roll styles (XdY and XdY ...
    (comp.lang.python)
  • Re: Singletons
    ... But Java supports static methods. ... I have shown a counter-example ... global functions. ...
    (comp.object)
  • How to use java class object in ASP.NET?
    ... I have to translate an ASP project to ASP.NET, in the former project, a java ... the object "ccb.pub.RSAsig" is a java class object registered by ... object Obj not include the method generateKeys, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: "static" prefix - to parallel "this" prefix
    ... Saying Java does things ... > of view doesn't mean the Smalltalk solution is what would work for Java. ... design decision - since static methods can't be overriden, ... as the "Inherited Java Singleton Problem". ...
    (comp.lang.java.programmer)
  • Re: difference between class and object methods
    ... object methods in ruby are equivalent object methods in java ... and class methods in ruby are equivalent STATIC functions in java? ... Java's static methods and variables are not class methods in the same ... class methods can be thought of as instance methods; ...
    (comp.lang.ruby)