I'm a C ++ fan who picks up Java for Android apps. In C ++, the canonical way to create and initialize an object would be to fully initialize it in the constructor:
class Message {
string payload;
int client;
public:
Message(string payload, int client)
: payload(payload)
, client(client)
{}
};
This is similar to Java. This gets a little ugly because I want to make certain members const(the best Java can do this final), but usually I can figure it out.
But now I am running libraries, such as FreeHEP-XDR, the interface XDRSerializableindicates a signature:
void read(XDRDataInput in);
, Message, , , void. Message , , , . : XDRDataInput , ( , read). , , final Message, !
Java? , ?