Search code examples
javaassert

Java Incompatible operand types void and Class<Void>


I'm implemebting some lists in java, but I encountered this problem.

assertTrue( list.remove( "A" ) == void);

Solution

    1. list.remove(Obj) returns you a boolean variable. Which returns true if the element was present and removed, and false if the element is not present.
    2. You cannot compare a type(keyword) in Java.

    If you are looking to check if an element was removed, you can check like list.remove("A") == false which will do the same thing.