I have two different programs, the one that uses int
and the other Double
.
For the below code am getting NullpointerException
public class Solution {
Double cost;
void addTax(Double b)
{
cost+=b;
}
public static void main(String[] args)
{
new Solution().addTax(30.00);
}
}
But for the below code that uses int isn't getting any runtime error.
public class Solution {
int cost;
void addTax(int b)
{
cost+=b;
}
public static void main(String[] args)
{
new Solution().addTax(30);
}
}
So how does that possible? Please explain me.