If you buy an apartment-size washing machine, it should be no problem. Ask the sales person first.
But I think there is a question to ask prior to purchasing a washing machine: Does the lease allow you to install a washing machine in your room? Most apartment buildings do not allow that. Some private rental units (in condo buildings) may allow it. It would be a real pain having to uninstall it and returning / selling it.