What do square brackets in Java method declarations mean?

前端 未结 5 1278
死守一世寂寞
死守一世寂寞 2021-01-06 05:12

The grammar for method declarations in Java is something like the following:

Java method declaration BNF:

method_declaration 
    ::= 
    { modifier         


        
5条回答
  •  长发绾君心
    2021-01-06 05:38

    { ... } stands for 0..* (zero times or more)

    The generics are missing because the document you linked is 17 years old.

    The official Java Language Specification uses this particular syntax: http://docs.oracle.com/javase/specs/jls/se7/html/jls-2.html#jls-2.4

    I wasn't able to find a real BNF grammar for Java which is less obsolete than yours.

提交回复
热议问题