سؤال

In Java, I found that some developers write:

public static functionName() {}

But some others write:

static public functionName() {}

What's the difference between these two?

هل كانت مفيدة؟

المحلول

From the Java Language Specification, section 8.4.3:

If two or more (distinct) method modifiers appear in a method declaration, it is customary, though not required, that they appear in the order consistent with that shown above in the production for MethodModifier.

So they can appear in any order, but there is a recommended ordering. The order is:

Annotation public protected private abstract static final synchronized native strictfp

نصائح أخرى

Both are the same. But still you are missing the return type of the method.

public static returnType functionName(){}

static public returnType functionName(){}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top