One returns Double; the other, double.

The differences between primitive Java types and their wrapper counterparts are discussed, for example, here.

Answer from NPE on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Double.html
Double (Java Platform SE 8 )
October 20, 2025 - Constructs a newly allocated Double object that represents the floating-point value of type double represented by the string. The string is converted to a double value as if by the valueOf method. Parameters: s - a string to be converted to a Double. Throws: NumberFormatException - if the string ...
Discussions

"double[] myList = new double[10]" -- super easy noob question. why is double necessary to be stated twice?
I'm going to use a List example to explain this, because it's pretty easy to see. An object in Java (and many other languages) has two parts. One is the actual object itself that lives on the heap. It contains information about the object, like member variables. The other part of the object is a reference which controls the object. The references know generally what kinds of actions you can take with the object. Think of the reference like a remote control and an object like a TV. When you declare an object, you have a two-part declaration. Let's say I want to create a dynamic list of integers. My declaration is going to look like this: ArrayList intList = new ArrayList(); The left side of the declaration tells the compiler what type the reference (remote control) is. Here I've been pretty specific and declared my intList reference as an ArrayList. However, I didn't need to. I could have also said: List intList = new ArrayList(); My remote control has become more general. It's kind of like using a universal remote, instead of the one that's designed specifically for your television. The right side of the = in the object declaration is telling Java what type of object it's allocating space for on the heap. This needs to be specific. I can't say intList is a List on the right side. The compiler won't let you do that, since List is an interface and not able to be instantiated. Now, why do we do this? A couple reasons, which all fall under the general heading of "Polymorphism". If I have my intList declared as a List instead of an ArrayList, I can pass it to any method that takes a List in its method signature. The same method would also be able to take anything else that implements the List interface, such as LinkedList. This becomes even more powerful when you build your own objects. Let's say you're writing some sort of program to run a farm. You'll probably have an Animal class, as well as a bunch of different things that inherit from Animal, such as Cow, Horse, and Pig. Let's also say you have a barn that you house the animals in. Instead of having three different ArrayLists for the animals in your barn, you can have a single ArrayList to hold them all. When you create it, you just say: List barnAnimals = new ArrayList(); And you'll be able to add any type of animal to it, instead of just horses or pigs. You can also declare any of the animals like so: Animal bessie = new Cow(); A final word of warning. If you do this, the only methods you'll be able to access from the reference (remote control) are the methods of the parent class you're declaring it as, in this case Animal. So you'd probably have eat() or sleep(), since those are common for all the animals on a farm, but you wouldn't be able to say bessie.milk(); with the way we've declared it. You'd have to first cast Bessie as a cow before you'd be able to do any cow-specific actions with her. More on reddit.com
🌐 r/learnjava
11
11
April 15, 2015
Double[] instead of double[] variable declarator
Hi everyone i have a problem with java snippet. when i need as output an array of double the snippet automaticaly set Double which doesn’t exist as type. Possible bug? More on forum.knime.com
🌐 forum.knime.com
0
March 6, 2018
Double array initialization in Java - Stack Overflow
I was reading a book on Java and came across an example in which an array of type double was initialized in a way that I haven't seen before. What type of initialization is it and where else can it... More on stackoverflow.com
🌐 stackoverflow.com
List<Double> vs double[]

Ohhhhh yes, there are differences. You are dealing with Lists vs Arrays. They are two different beasts. The most important difference (in my mind) is that an array has a set size, whereas a list can grow or shrink to fit the elements it contains. However, there are a lot of other significant differences, so I would encourage you to just Google ArrayList vs Array and read an article or two about it. I'm on my phone so I can't write much of an extensive answer myself, and most resources you'll find in a Google search will do a better job than I would anyways.

As for the Double vs double usage, a List must have objects as elements, whereas arrays can contain objects or primitives (e.g integers and doubles). Double is essentially an object version of the primitive double (really it's a wrapper class, but that's not something you should worry about too much right now). Hope that helps clear it up a bit...

More on reddit.com
🌐 r/learnjava
5
5
April 13, 2017
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-lang-double-class-java
Java.Lang.Double Class in Java - GeeksforGeeks
July 23, 2025 - // Java Program to Illustrate Double ... double b = 55.05; String bb = "45"; // Construct two Double objects Double x = new Double(b); Double y = new Double(bb); // Method - toString() System.out.println("toString(b) = " + ...
🌐
Reddit
reddit.com › r/learnjava › "double[] mylist = new double[10]" -- super easy noob question. why is double necessary to be stated twice?
r/learnjava on Reddit: "double[] myList = new double[10]" -- super easy noob question. why is double necessary to be stated twice?
April 15, 2015 -

As in, the way Java works, why was it designed this way.. I understand double[] myList but why is it necessary to state double... same thing with like... Scanner input = new Scanner(System.in)

it just feels... redundant.. but im at such a low level, my curiosity got to me. whats the utility of this?

can you show me a short line of code that shows the deeper complexity of declaring a new instance.

id imagine its just a syntax thing built into java/previous languages.. but i guess from my experience with higher level languages seem to have really simplified the type of statement above

Top answer
1 of 5
8
I'm going to use a List example to explain this, because it's pretty easy to see. An object in Java (and many other languages) has two parts. One is the actual object itself that lives on the heap. It contains information about the object, like member variables. The other part of the object is a reference which controls the object. The references know generally what kinds of actions you can take with the object. Think of the reference like a remote control and an object like a TV. When you declare an object, you have a two-part declaration. Let's say I want to create a dynamic list of integers. My declaration is going to look like this: ArrayList intList = new ArrayList(); The left side of the declaration tells the compiler what type the reference (remote control) is. Here I've been pretty specific and declared my intList reference as an ArrayList. However, I didn't need to. I could have also said: List intList = new ArrayList(); My remote control has become more general. It's kind of like using a universal remote, instead of the one that's designed specifically for your television. The right side of the = in the object declaration is telling Java what type of object it's allocating space for on the heap. This needs to be specific. I can't say intList is a List on the right side. The compiler won't let you do that, since List is an interface and not able to be instantiated. Now, why do we do this? A couple reasons, which all fall under the general heading of "Polymorphism". If I have my intList declared as a List instead of an ArrayList, I can pass it to any method that takes a List in its method signature. The same method would also be able to take anything else that implements the List interface, such as LinkedList. This becomes even more powerful when you build your own objects. Let's say you're writing some sort of program to run a farm. You'll probably have an Animal class, as well as a bunch of different things that inherit from Animal, such as Cow, Horse, and Pig. Let's also say you have a barn that you house the animals in. Instead of having three different ArrayLists for the animals in your barn, you can have a single ArrayList to hold them all. When you create it, you just say: List barnAnimals = new ArrayList(); And you'll be able to add any type of animal to it, instead of just horses or pigs. You can also declare any of the animals like so: Animal bessie = new Cow(); A final word of warning. If you do this, the only methods you'll be able to access from the reference (remote control) are the methods of the parent class you're declaring it as, in this case Animal. So you'd probably have eat() or sleep(), since those are common for all the animals on a farm, but you wouldn't be able to say bessie.milk(); with the way we've declared it. You'd have to first cast Bessie as a cow before you'd be able to do any cow-specific actions with her.
2 of 5
1
It has to do with classes and inheritance from what I understand. If the FantasyNovel class inherits the Book class, then you could declare a fantasy novel as a book. Someone who has done this in practice would be a better source and you should double check me.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › Double.html
Double (Java SE 17 & JDK 17)
January 20, 2026 - See Java Language Specification: 15.20.1 Numerical Comparison Operators <, <=, >, and >= Since: 1.2 · public static int compare · (double d1, double d2) Compares the two specified double values. The sign of the integer value returned is the same as that of the integer that would be returned ...
🌐
DataCamp
datacamp.com › doc › java › double
double Keyword in Java: Usage & Examples
Java keywordsIntroduction To JavaJava File HandlingJava Language BasicsJava ArraysJava Object-Oriented Programming ... The double keyword in Java is a primitive data type that represents a double-precision 64-bit IEEE 754 floating point.
🌐
Quora
quora.com › What-is-the-difference-between-double-d-new-Double-String-and-double-d-Double-parseDouble-String-in-Java
What is the difference between ' double d = new Double (String)' and ' double d = Double.parseDouble (String)' , in Java? - Quora
Both throws NumberFormatException if incorrect string value if given. Now the difference lies in what both of them return: new Double(String) is used when you want to create a Double instance . Since your first co...
Find elsewhere
🌐
KNIME Community
forum.knime.com › knime extensions
Double[] instead of double[] variable declarator - KNIME Extensions - KNIME Community Forum
March 6, 2018 - Hi everyone i have a problem with java snippet. when i need as output an array of double the snippet automaticaly set Double which doesn’t exist as type. Possible bug?
🌐
Coderanch
coderanch.com › t › 409330 › java › Double-double-difference
Double and double - what's the difference? (Beginning Java forum at Coderanch)
January 31, 2008 - It returns double, not Double. That should solve your problem. You should have got a compile time error because of this. However, if you are using JDK 1.5 or above then you would not get this problem. ... Originally posted by ankur rathi: You should have got a compile time error because of this. Opps... You got compile time error only. The error confused me. It should be: found: java.lang.Double expected or required: double
🌐
W3Schools
w3schools.com › java › ref_keyword_double.asp
Java double Keyword
Java Examples Java Videos Java ... Plan Java Interview Q&A Java Certificate ... The double keyword is a data type that can store fractional numbers from 1.7e−308 to 1.7e+308....
🌐
Jérôme Pilliet
igm.univ-mlv.fr › ~juge › javadoc-19 › java.base › java › lang › Double.html
Double (Java SE 19 & JDK 19)
See Java Language Specification: 15.20.1 Numerical Comparison Operators <, <=, >, and >= Since: 1.2 · public static int compare · (double d1, double d2) Compares the two specified double values. The sign of the integer value returned is the same as that of the integer that would be returned ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › double-parsedouble-method-in-java-with-examples
Double parseDouble() method in Java with examples - GeeksforGeeks
July 11, 2025 - The parseDouble() method of Java Double class is a built in method in Java that returns a new double initialized to the value represented by the specified String, as done by the valueOf method of class Double.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Float-vs-Double-Whats-the-difference
Java double vs float: What's the difference?
Both data types represent numbers with decimals, but a float is 32 bits in size while a double is 64 bits. A double is twice the size of a float — thus the term double. In Java, the Float and Double wrapper classes have two properties that return the upper and lower limits of float and double data types, MIN_VALUE and MAX_VALUE:
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-convert-string-to-double
Java Convert String to double | DigitalOcean
August 3, 2022 - Java String to double conversion can be done by many ways. Today we will look into some common ways to convert java string to double primitive data type or Double object.
🌐
Huda Tutorials
hudatutorials.com › java › basics › java-arrays › java-double-array
Java double Array - double Array in Java
May 18, 2024 - Double arrays can be declared and initialized in various ways, depending on the requirements: Declaration: double[] doubleArray; Initialization with a Specific Size: doubleArray = new double[5]; Initialization with Values: double[] initializedArray ...
🌐
TutorialsPoint
tutorialspoint.com › home › java/util › arrays.fill() method in java
Java Arrays fill(double[], double) Method
September 1, 2008 - Actual values: Value = 10.0 Value = 20.0 Value = 15.0 New values after using fill() method: Value = 0.0 Value = 0.0 Value = 0.0 · The following example shows the usage of Java Arrays fill(double[], int, int, double) method. First, we've created an array of doubles and its elements are printed.
🌐
Reddit
reddit.com › r/learnjava › list vs double[]
r/learnjava on Reddit: List<Double> vs double[]
April 13, 2017 -

What are the major differences between the two? I know Double and double are different, so I guess my question is more on the collections. Is there anything important to consider when working with one collection vs the other?

I have an example: https://pastebin.com/2qM9vBsu

The goal of the method is to add arrays/lists similar to vector addition. IE, sumList([3, 6], [2, 1]) would return [5,7].

I can already tell that there are some differences with, I realize working with List<Double> I'll have access to class Double methods whereas double is a primitive. Is there anything about the collection types that I should know?

🌐
Coderanch
coderanch.com › t › 678444 › java › Enter-double-values-single-line
Enter double values into a single line, and then put into an array? (Beginning Java forum at Coderanch)
It's the quizScores[i] = Double.parseDouble(quizScoresInputStr); line. ... You are passing the string for the line, not separated strings. ... JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-17 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility
🌐
Trinket
books.trinket.io › thinkjava › chapter8.html
Arrays | Think Java | Trinket
These statements create an array of three doubles and make two different variables refer to it, as shown in Figure 8.3. Any changes made through either variable will be seen by the other. For example, if we set a[0] = 17.0, and then display b[0], the result is 17.0. Because a and b are different names for the same thing, they are sometimes called aliases. If you actually want to copy the array, not just a reference, you have to create a new array and copy the elements from the old to the new, like this: