`
d02540315
  • 浏览: 31443 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
最近访客 更多访客>>
社区版块
存档分类
最新评论

Marker Interface

    博客分类:
  • JDK
阅读更多
Marker interface having no methods right.. then what is the use of marker interface? for what purpose we use marker interface?

One of the "clean" features of the Java programming language is that it mandates a separation between interfaces (pure behavior) and classes (state and behavior). Interfaces are used in Java to specify the behavior of derived classes.
Often you will come across interfaces in Java that have no behavior. In other words, they are just empty interface definitions. These are known as marker interfaces. Some examples of marker interfaces in the Java API include:


- java,lang.Cloneable
- java,io.Serializable
- java.util.EventListener

Marker interfaces are also called "tag" interfaces since they tag all the derived classes into a category based on their purpose. For example, all classes that implement the Cloneable interface can be cloned (i.e., the clone() method can be called on them). The Java compiler checks to make sure that if the clone() method is called on a class and the class implements the Cloneable interface. For example, consider the following call to the clone() method on an object o:

SomeObject o = new SomeObject();
SomeObject ref = (SomeObject)(o.clone());

If the class SomeObject does not implement the interface Cloneable (and Cloneable is not implemented by any of the superclasses that SomeObject inherits from), the compiler will mark this line as an error. This is because the clone() method may only be called by objects of type "Cloneable." Hence, even though Cloneable is an empty interface, it serves an important purpose.
分享到:
评论

相关推荐

    Android代码-StickyHeaders

    StickyHeaders Easily add Sticky Headers to your RecyclerView Setup Implement StickyHeaderHandler in your...For items in your dataset that you want to act as sticky headers, implement the marker interface

    ccna实验之ppp 用的是繁荣模拟器

    *Mar 1 00:02:38.923: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/2, changed state to up r1(config-if)#end r1#sh run Building configuration... *Mar 1 00:02:58.663: %SYS-5-CONFIG_I: ...

    WinQTLCart

    WinQTLCart incorporates the modules found in its command-line sibling, QTL Cartographer, and provides a graphical interface to QTL Cartographer's features. What’s new 1. Add new function: Import ...

    谷歌地图 delphi 封装库 2013 0.1.9 全面支持google maps api

    - Improvement: TBasePolyline -> implements ILinePoint interface September 11, 2012 - Google Maps Library v0.1.7 - bug fixed: some memory leaks fixed (there is still some) (thanks Donovan) - ...

    leaflet-lasso:单张的套索选择插件

    小叶套索 单张的套索选择插件 支持所有Leaflet向量层: 记号笔CircleMarker 圆圈折线多段折线长方形多边形带Kong的多边形具有多个线段的多边形具有多个线段和Kong的多边形选择方式: 包含-整个形状必须为套索多边形...

    添加H.264代码

    // receiving interface (label) dir_t direction_; // direction: 0=none, 1=up, -1=down // source routing char src_rt_valid; double ts_arr_; // Required by Marker of JOBS //Monarch extn begins ...

    simple-tags

    * Remove old marker <!--st_tag_cloud--> * Remove related posts * Remove related tags * Remove tags as HTML keywords * Remove nofollow options * Remove custom function for display current post ...

    JPEG2000 C语言源代码全集

    application of registration offsets in the CRG marker segment; and colour conversion to an appropriate rendering space (sRGB here). The "kdu_region_decompressor" object provides extensive support ...

    Python for Bioinformatics 第二版,最新版

    Chapter 22 Drawing Marker Positions Using Data Stored in a Database 355 22.1 PROBLEM DESCRIPTION 355 22.1.1 Preliminary Work on the Data 355 22.1.2 MongoDB Version with Commented Source Code 358 ...

    Dundas.Chart.for.Winform.Enterprise.v7.1.0.1812.for.VS2008

    New User Interface functionality is also available in the latest release, consisting of Toolbars, Property Pages, Context Menus and Chart Commands. Other additions include Data Point Label ...

    基于ON NCN5130的KNX双绞线收发器的智能楼宇方案 -电路方案

    • Selectable UART or SPI Interface to Host Controller • Selectable UART and SPI baud Rate to Host Controller • Optional CRC on UART to the Host • Optional Received Frame−end with MARKER Service ...

    Visual C++ 编程资源大全(英文源码 其它)

    1,01.zip Output 显示所有的调试信息(5KB)<END><br>2,02.zip Some general debugging tips 一般的调试技巧(11KB)<END><br>3,03.zip Debugging ISAPI extension 调试ISAPI扩展(4KB)<END><br>4,04....

    EhLib 8.0 Build 8.0.023 Pro Edition FullSource for D7-XE8

    Title can act as button and, optionally show a sort marker. Automatically sortmarking. Ability to truncate long text with ellipsis. Lookup list can show several fields. Incremental search in ...

    EhLib 6.3 Build 6.3.176 Russian version. Full source included.

    Title can act as button and, optionally show a sort marker. Automatically sortmarking. Ability to truncate long text with ellipsis. Lookup list can show several fields. Incremental search in ...

    EhLib5.0.13 最新的ehlib源码

    Title can act as button and, optionally show a sort marker. Automatically sortmarking. Ability to truncate long text with ellipsis. Lookup list can show several fields. Incremental search in ...

    ehlib_vcl_src_9_3.26

    Title can act as button and, optionally show a sort marker. Automatically sortmarking. Ability to truncate long text with ellipsis. Lookup list can show several fields. Incremental search in ...

    EhLib 9.1.024

    Title can act as button and, optionally show a sort marker. Automatically sortmarking. Ability to truncate long text with ellipsis. Lookup list can show several fields. Incremental search in ...

    Visual C++ 编程资源大全(英文源码 网络)

    bridge.zip Bridge Pattern - Bridging the gap between Interface and Implementation (40KB)<END><br>76,method.zip Function Pointers to Non-Static Object Methods(24KB)<END><br>77,singleton.zip ...

    cmd操作命令和linux命令大全收集

    route print 显示出IP路由,将主要显示网络地址Network addres,子网掩码Netmask,网关地址Gateway addres,接口地址Interface arp 查看和处理ARP缓存,ARP是名字解析的意思,负责把一个IP解析成一个物理性的MAC...

Global site tag (gtag.js) - Google Analytics