I learned from looking at other references & SO that the Double
has a lot of disadvantages.
Double disadvantages compared to double primitive data type:
- It is slower (reference : Java Double vs double: class type vs primitive type)
- It take more storage because of the metadata involved with it.
Now, I know there are some manipulation what we can do With Double. JavaDoc but most (85%) of these methods are static there fore it not a huge advantage. Another thing I know that double cannot be null.
Double doubleClass = null; // Is valid
double doubleType = null; // Results in NPE
After all these disadvantages I cannot understand why we would use Double and not double in real life scenario. Can some give a real world example and explain.
Thanks