We can store
Integer a= 12;
But we can't store like this
BigDecimal b =12;// what is the reason for that
We can store
Integer a= 12;
But we can't store like this
BigDecimal b =12;// what is the reason for that
BigDecimal is not a primitive. In order to have a BigDecimal you need to create an instance of it like BigDecimal b = new BigDecimal(12);
. From there you can call its various methods to do math with it, round it, etc.
With very, very few exceptions all Java Objects require that you assign the variable with an object of that type (or whatever follows the rules of polymorphism).