I am stuck on a problem, I am not sure how to do it,
for ( int i = 0; i < n1; i++ )
{
int value = hmap2.get(arr1[i]);
if ( value != 0 || value != null )
{
System.out.print(arr1[i]+" ");
hmap2.put(arr1[i], --value);
}
}
In this code snippet, the variable value
will have a null value when arr1[i]
doesn't exist in the map. So when this happens I don't want to print the arr[i]
value. How can I do it because it is throwing error can't compare arguments? what am I doing wrong?
I want to make sure that when there is no mapping for arr1[i]
in the map, I should skip it and not print it.