Double is an object and double is a primitive data type. See this answer for more details.
The Double class wraps a value of the primitive type double in an object. An object of type Double contains a single field whose type is double.
Source: http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html
Answer from But I'm Not A Wrapper Class on Stack OverflowI am learning Java, and am confuse on when to choose double or float for my real numbers or int. It feels like, it doesn’t matter because from my limited experience (with Java) both of them deliver the same results, but I don’t want to go further down the learning curve with Java and have a bad habit of using either messing up my code, and not having a clue as to why. So, when should you use float and double?
Videos
I was playing around in an editor and divided 9 by 2 and to my surprise it truncated the decimal so I got 4 instead of 4.5. So I was like, oh right, so must be / floor division, it just truncates the decimal.
So then I tried to do 4 // 5, which is either invalid because / must be the escape character, or I can't do regular division because they're both ints, not sure which, but I got an error.
If I create 9 as a double and try 9 / 2, it divides correctly and I get 4.5
Should I always use doubles just in case? What if there's an instance where a large program uses ints and outputs unexpected numbers because the decimals have all been truncated?
Double parameter can be null when double can't.
First off you need to understand the difference between the two types.
double is a primitive type whereas Double is an Object.
The code below shows an overloaded method, which I assume is similar to your lab code.
void doStuff(Double d){ System.out.println("Object call"); }
void doStuff(double d){ System.out.println("Primitive call"); }
There are several ways you can call these methods:
doStuff(100);
doStuff(200d);
doStuff(new Double(100));
These calls will result in:
"Primitive call"
"Primitive call"
"Object call"