I have the following code:
private static double calcTotalMass() { return bike_mass + human_mass; }
private static double calcWeight() { return calcTotalMass() * grav_acc; }
private static double calcWork() { return calcWeight() * height; }
...
Since in Java everything is in a class and I can't define global functions, static
and an access specifier is necessary.
In C++ I could shorten the first function to just
double calcTotalMass() { return bike_mass + human_mass; }
In Julia it'd be
calcTotalMass() = bike_mass + human_mass
but that's a different story.
In C++ access specifiers are in groups that way the private
does not have to be repeated for each method. Is there something similar in Java or is this just how the language is built?