News for hackers. Stuff that matters.
Re:The use of ‘class’ for things that should be simple free ... by amluto on Sunday May 29, 2022 @11:53AM (#31550110)
Unless I’ve missed a radical change in recent Java versions, Java doesn’t have free functions per se. So asking Java programmers will give biased answers.
Re:The use of ‘class’ for things that should be simple free ... by fendy3002 on Sunday May 29, 2022 @12:00PM (#31550183)
Afaik yes, java doesn't. The closest will be static class and functions.
Re:The use of ‘class’ for things that should be simple free ... by leetcrew on Sunday May 29, 2022 @01:40PM (#31551031)
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++.

Re:The use of ‘class’ for things that should be simple free ... by watwut on Sunday May 29, 2022 @03:02PM (#31551827)
What 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.

Re:The use of ‘class’ for things that should be simple free ... by ziml77 on Sunday May 29, 2022 @04:34PM (#31552644)
They 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.