`
leonzhx
  • 浏览: 793710 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Item 36: Consistently use the Override annotation

阅读更多

1.  Override annotation can be used only on method declarations, and it indicates that the annotated method declaration overrides a declaration in a supertype. If you consistently use this annotation, it will protect you from a large class of nefarious bugs.

 

2.  You should use the Override annotation on every method declaration that you believe to override a superclass declaration.

 

3.  If you enable the appropriate code inspection, the IDE will generate a warning if you have a method that doesn’t have an Override annotation but does override a superclass method. If you use the Override annotation consistently, these warnings will alert you to unintentional overriding. These warnings complement the compiler’s error messages, which alert you to unintentional failure to override. Between the IDE and the compiler, you can be sure that you’re overriding methods everywhere you want to override them and nowhere else.

 

分享到:
评论

相关推荐

    Effective Java 3rd edition(Effective Java第三版英文原版)附第二版

    Item 40: Consistently use the Override annotation Item 41: Use marker interfaces to define types 7 Lambdas and Streams Item 42: Prefer lambdas to anonymous classes Item 43: Prefer method references to...

    源代码——GlobFit: Consistently Fitting Primitives by Discovering Global Relations

    《源代码——GlobFit: 全局关系发现下的一致原始件拟合》 GlobFit是一款用于几何建模和3D数据处理的工具,它专注于通过发现全局关系来实现一致的原始件(如直线、圆弧、平面等基本几何元素)的精确拟合。...

    Google C++ Style Guide_英文版.pdf

    - **The #define Guard:** Use a unique macro name to prevent multiple inclusions of the same header file. For example: ```cpp #ifndef MYHEADER_H_ #define MYHEADER_H_ // header content #endif ``` ...

    NGUI Next-Gen UI 3.0.7 f1.unitypackage

    - NEW: Re-created the Anchor Example to use the new anchoring system. - NEW: Updated all controls to use the new anchoring system. - NEW: You can now specify an explicit Render Queue on each panel. - ...

    bds.en.iso.14982.2009

    - **Reliability:** To ensure that the electronic systems within the machinery function correctly and consistently, even in harsh environmental conditions. - **Interoperability:** To allow for the ...

    RxLib控件包内含RxGIF,全部源码及DEMO

    PLEASE FOLLOW THE INSTRUCTIONS PROVIDED IN THE INSTALLATION SECTION! TABLE OF CONTENTS ----------------- Latest Changes Overview History License Agreement Installation Demonstration Programs Source ...

    How.to.Use.Objects.Code.and.Concepts.0321995546

    While most developers today use object-oriented languages, the full power of objects is available only to those with a deep understanding of the object paradigm. How to Use Objects will help you gain ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Of course, .cc files typically do require the definitions of the classes they use, and usually have to include several header files. Note: If you use a symbol Foo in your source file, you should ...

    Android 4.0 Compatibility Definition

    Text-to-speech compatibility ensures that applications can use the built-in TTS engine consistently across devices. #### 4. Application Packaging Compatibility This section covers the packaging of ...

    Direct Memory Access in Linux.doc

    The challenge lies in consistently accessing the same physical memory space and preventing the kernel from using it for other purposes. #### Exploring Solutions To address these requirements, ...

    1613104635615_Tuning Dampers for Ride and Handling of Production Vehicles.pdf

    Tuned dampers ensure that the vehicle reacts consistently to similar inputs, allowing the driver to anticipate how the car will behave in different scenarios. Ride Attributes Affected by Dampers On...

    微软内部资料-SQL性能优化2

    The boot.ini option /3GB was created for those cases where systems actually support greater than 2 GB of physical memory and an application can make use of it This capability allows memory intensive ...

    Learn Python the Hard Way

    Shaw teaches the Python programming language through a series of 52 brilliantly-crafted exercises-all formatted consistently, and most no longer than two pages (including 'extra credit'). Just read ...

    Flash.CS5.The.Missing.Manual

    Despite the many improvements in software over the years, one feature has grown consistently worse: documentation. With the purchase of most software programs these days, you don’t get a single page ...

    IABC-Brand Guidelines(32p)_大厂VI品牌视觉标准_外企业品牌手册.pdf

    Consistent use of IABC's chosen colors across all materials ensures a strong visual connection. IABC LogoThe logo is the most recognizable symbol of the brand, representing IABC at a glance. It ...

    ethminer-0.16.0.dev3

    [Genoil's fork] was the original source of this version, but as Genoil is no longer consistently maintaining that fork it became almost impossible for developers to get new code merged there. In the ...

    statistica 全套教程包括数据挖掘

    5. **Reliability and Item Analysis**: Evaluates the consistency and reliability of measurement instruments. 6. **Classification Trees**: Builds decision trees for classification problems. 7. **...

Global site tag (gtag.js) - Google Analytics