Well, it depends.
In the second case, the value will be populated with its default value of 0 , only for reassignment when created with 100 . In the first case, value immediately gets the value 100 .
Semantically, this would help the programmer - they would see that this particular value means more than just arbitrary (although it should be a constant value somewhere).
Programmatically, there is no pain if the primitive is set to some initial value. This means that there is something for you, and if your program depends on the presence of a non-negative or false value, George will work.
Things become more explicit when working with object references. Take, for example, these two classes:
public class Foo { List<String> elements; public Foo() { } public Foo(String... items) { elements = new ArrayList<>(); for(String item : items) { elements.add(item); } } } public class Bar { List<String> elements = new ArrayList<>(); public Bar() { } public Bar(String... items) { for(String item : items) { elements.add(item); } } }
There are intentionally no-arg constructors to clog the home point - for Foo , if I try to use elements , then I have a bit of a problem, if I don't use the corresponding constructor - elements is null ! * Then I could just create an instance when I need it, but I would really like to avoid destroying a potentially new and populated list.
That means a lot of code looks something like this:
if(elements == null) { elements = new ArrayList<>(); }
... then I have to worry about being thread safe. Sheesh, talk about the chores.
With Bar I am guaranteed that when you instantiate it, it has an instance of the list in elements , so I donβt have to worry about being null . **
This is called impatient creation . You really do not want to live without this object, so why wait until you think that you need it (or a lazy instance )?
*: the default value for all link types is null .
**: You need to worry about this being texted, but this is a problem that goes beyond the scope of this question.