I have an interesting question. I understand the following C# code enables users to input null values in parameters:
public DateTime? date (DateTime dt) {}
What is the equivalent when coding in Java?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I recall correctly each object in java can be nullable.
Primitive types (
int, double, float, charetc…) cannot be null. For using null with them you have to use their Object counterpart (Integer, Double, Float...)Regarding dates, java.util.Date is an Object, so it can be null. Same goes for Calendar & GregorianCalendar.
equivalent code will be something like:
In C# you can use ? to allow null val in primitive types (e.g. to enforce object null reference errors). I don’t understand why this thing bothers you. If you need for example a nullable integer parameter in java, you simply have to use
java.lang.Integerand not primitiveinttype.