I have a class such as :
class node
{
Integer id ;
double lon;
double lat ;
.....
}
There is a method in other class takes arguments from node class , and do some operation by them ….
in this method , there is condition like (node1.getId == node2.getId) …
Now I need to give this method node1 , node2 argument where the id of node1 = null ..
when it compares between (node1.getId == node2.getId) , NullpointerException is thrown …
Is there an integer type in Java that I can compare objects of it with null ?? like “int? ” in C# ..
No there is nothing like the
?. If there is a possibility fornull, you have to test for it.So,