Could be dumb question, but how can I pass null to method which takes long or int?
Example:
TestClass{
public void iTakeLong(long id);
public void iTakeInt(int id);
}
now how can i pass null to both methos:
TestClass testClass = new TestClass();
testClass.iTakeLong(null); // Compilation error : expected long, got null
testClass.iTakeInt(null); // Compilation error : expected int, got null
Thoughts, suggestions?
The problem is that
intandlongare primitives. You can’t passnullto a primitive value.You can certainly use the wrapper classes
IntegerandLonginstead oflongandintin your method signature.