How are ethics different from law?

Ethics are voluntary but law is compulsory to be followed.