How to use readObject in java socket?

I want to send each updated UI object to the Server via writeObject loop, and then the Server accepts it with readObject(). But it failed. No matter how many times I loop, the Server will always only read this UI@26775a6.
What’s going on?



Without seeing the entire code, it looks to me like you are trying to write / read multiple UI instances. I.e. in the client you loop over your UI objects, calling writeObject() for each one; on the server, you’re looping, calling readObject() to get individual UI objects.

Others have reported much difficulty when trying to do this. For instance.

Unless you have a specific requirement to do otherwise, I suggest putting all your UI objects in a list, and do the writeObject / readObject using the list. Lists are serializable, so that should “just work”.