The term syntactic sugar typically refers to cases where the feature is defined by a trivial substitution. So theThe language doesn't define what a feature does, instead it defines what itsthat it is exactly equivalent to something else. So for example, for-each loops
for(Object alpha: alphas) {
}
Becomes:
for(Iterator<Object> iter = alpha.iterator(); iter.hasNext()) {
alpha = iter.next();
}
Or take a function with variable arguments:
void foo(int... args);
foo(3, 4, 5);
Which becomes:
void Foo(int[] args);
foo(new int[]{3, 4, 5});
So there is a trivial substitution of syntax to implement the feature in terms of other features.
Let's look at method overloading.
void foo(int a);
void foo(double b);
foo(4.5);
This can be rewritten as:
void foo_int(int a);
void foo_double(double b);
foo_double(4.5);
But its not quite as trivial, and itsit is not how java definesequivalent to that. Within the featuremodel of Java, this is something different. Methodfoo(int a) doesn't implement a foo_int function to be created. Java doesn't implement method overloading isn't defined as calling methods with specialby giving ambiguous functions funny names. Yes, that's equivalent in some wayTo count as syntactic sugar, java would have to be pretending that you really wrote foo_int and foo_double functions but that's simply not how the feature is definedit doesn't.