File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Incompatible types error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Incompatible types error" Watch "Incompatible types error" New topic

Incompatible types error

Thomas Kennedy
Ranch Hand

Joined: Jan 20, 2008
Posts: 137

produces incompatible types
found : java.util.Enumeration<capture of ?>
required: java.util.Enumeration<java.lang.String>
Enumeration<String> e = p.propertyNames();

while this

compiles ok.

What is the problem?

Costs matter. Justice lies in processes not outcomes. Crime is caused by criminals.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15082

Class Properties was from before the time that generics were added to Java. So the method propertyNames() returns a raw Enumeration, and not an Enumeration<String>.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Incompatible types error
It's not a secret anymore!