no ordinary "function" in java?

java

Solution

The closest thing you can have to a "free-floating" function is a static function, which you can call as qualified with the class name, e.g.

public class Foo {
   public static void bar(){}
}

... elsewhere

Foo.bar();

You can add a bit of syntactic sugar to this to make it look like what you're thinking of:

import static Foo.bar;

... elsewhere

bar();

Problem

in php you can declare a function in a global scope with function. is this not possible in java? looks like every function is in a class as a method. so everything is OOP in java? no procedural code?

Original source