Why is the order of return types important when defining methods in Java?

public void static final finalMethod()
public void static final finalMethod()
{ 

//This throws error saying "Syntax error on token                       
//"void",volatile expected"

}

public static final void finalMethod()
{

}

Work well Why do orders play an important role in defining methods? Why does Java expect volatile keywords here?

Solution

Because of how it is designed

Compiling is more than magic It parses the code and must follow a specific syntax to interpret it correctly

Grammar is grammar, that's it

The rules are enforced Grammar is like rules They must be observed

I can't understand this in depth, just like the specification, because I'm not a Java encoder I write c#, but the above applies to most compiled languages

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>