Inferred Types
With variable declarations, you can use var
to let Java figure out the type
of the variable.
var name = "Jupiter";
This is not allowed with argument declarations.
// You aren't allowed to use var for arguments!
void makeHorchata(var milkFatPercent) {
// ...
}
You must always explicitly write out the types of arguments.
void makeHorchata(double milkFatPercent) {
System.out.println(
"Making a horchata with " + milkFatPercent + "% milk."
);
}