4 ms·
you can't have a static outer class in java; static classes must be defined inside of a non-static class. AFAIK, the closest you can get to free functions is a
by leetcrew 4y ago
you can't have a static outer class in java; static classes must be defined inside of a non-static class.
AFAIK, the closest you can get to free functions is a non-static class that only has static functions. infuriatingly, many coverage tools will count the "constructor" of this class as uncovered code. stuff like this makes me really miss C++.
- watwut 4y agoWhat so you mean by that? By static class people typically mean that every method has static in it, so you never have reason to create an instance. Static inside inner class is something else entirely and has nothing to do with topic of this thread.
- ziml77 4y agoThey may be trying to say that Java doesn’t have static classes that match C# static classes. In C# if a class is marked static it’s enforced as not being able to be instantiated and all of its methods (and fields) must be static.