Because your id in the c1 instance is still null.
You should write a constructor to set the id and throw an Exception if null is passed. Similarly in the setId method. You asked about it in another
thread.
If you have to permit nulls, use
this method instead of calling equals directly. You can also use
this method to prevent nulls entering your class.