现在的位置: 首页 > 综合 > 正文

关于java方法的一些东西(摘自JLS)

2014年11月23日 ⁄ 综合 ⁄ 共 662字 ⁄ 字号 评论关闭

Ⅰ、Method Modifiers

Method modifiers include: Annotation, public, protected, private, abstarct, static, final synchronized, native, strictfp

A compile-time error occurs if a method declaration that contains the keyword abstract also contains any one of the keywords: private, static, final, native, strictfp or synchronized.

A compile-time error occurs if method declaration that contains the keyword native also contains strictfp.

At runtime, a machine-code generator of optimizer can "inline" the body of a final method.

Ⅱ、Overriding , Hiding

A compile-time error occurs if an instance method override a static method.

A comiple-time error occurs if a static method hides an instance method.

BUT it permissible for an instance variable to hide a static variable vice versa.

抱歉!评论已关闭.