Originally Posted by
amit1983
1. What do you mean when you write: " change the *state* of the object the Receive receives" ?
(can you give me an example ?)
If your class has public fields (and this is your case), simply access those fields (e.g.
obj.field = something;). However having public fields is not generally a good "design". It's better to keep fields
private and provide
public "accessor" methods like setXyz/getXyz. This is a basic concept about Java "beans". For example:
obj.setXyz(.....);
This is the meaning of "change the state of the object".
Originally Posted by
amit1983
2. If I want to return byte[], is it possible ?
if so, how I can deliver the length of the byte[] ?
Yes, it's possible to return a byte[]. Every array has an implicit length field. So the length is always known.
But in your case, note that if you return a byte[], its content is a serialized object. And deserialization is the responsibility of the caller. This is not a very good design. You should hide this aspect into the method, like you have done in the Send method.