Supposed that, I have a class named of RequestType
. In Java, code tends not to have any check for a new object being a null reference:
RequestType request = new RequestType();
// if (request == null) // missing
But C++ code tends to check the allocation:
RequestType* request = new RequestType();
if (nullptr == request) // check
Why do we need to check whether requestType is nullptr
in C++, but can just use it without such a check in Java?