10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TYPES, VALUES, AND VARIABLES Raw Types 4.8<br />

DISCUSSION<br />

For example,<br />

import java.util.*;<br />

class NonGeneric {<br />

Collection myNumbers(){return null;}<br />

}<br />

abstract class RawMembers extends NonGeneric implements Collection<br />

{<br />

static Collection cng =<br />

new ArrayList();<br />

public static void main(String[] args) {<br />

RawMembers rw = null;<br />

Collection cn = rw.myNumbers(); // ok<br />

Iterator is = rw.iterator(); // unchecked warning<br />

Collection cnn = rw.cng; // ok - static member<br />

}<br />

}<br />

RawMembers inherits the method<br />

Iterator iterator()<br />

from the Collection superinterface. However, the type RawMembers inherits<br />

iterator() from the erasure of its superinterface, which means that the return type of<br />

the member iterator() is the erasure of Iterator

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!