Why does for-each not work with Enumeration?

I'm sure there's some reason for this but I don't know what it would be.
I am calling an existing method [http://java.sun.com/javase/6/docs/api/java/util/zip/ZipFile.html#entries()] And it returns Enumeration<? extends ZipEntry>
What I would like to do is
Enumeration<? extends ZipEntry> entries = myzipfile.entries();
for(ZipEntry ze : entries)but this won't compile because Enumeration is not an Iterator. Which kinda sucks.
Obviously (I think) Enumeration can't be retrofit to be an Iterator without problems and the APIs that return Enumeration can't change without problems so it seems the only way that for-each would work with an Enumeration is if for-each was allowed to work with Iterator and Enumeration.
So my question is, why isn't it? (To be clear I know how to enumerate an Enumeration, I'd just like to know if anybody has a clue why for-each was not designed to support Enumeration)

Still it does'nt fully answer the why question. Why does the Collections class not implement a static iterable(Enumeration) method that does not impose the overhead of an addiditional ArrayList, as in the following class:
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class EnumerationToIterable {
    public static <T> Iterable<T> iterable(final Enumeration<T> enumeration) {
     return new Iterable<T>() {
         @Override
         public Iterator<T> iterator() {
          return new Iterator<T>() {
              @Override
              public boolean hasNext() {
               return enumeration.hasMoreElements();
              @Override
              public T next() {
               return enumeration.nextElement();
              @Override
              public void remove() {
               throw new UnsupportedOperationException();
    public void iterateOne(ZipFile myzipfile) {
     Enumeration<? extends ZipEntry> entries = myzipfile.entries();
     for (ZipEntry ze : Collections.list(entries)) {
         // process ze
    public void iterateTwo(ZipFile myzipfile) {
     Enumeration<? extends ZipEntry> entries = myzipfile.entries();
     for (ZipEntry ze : iterable(entries)) {
         // process ze
}Could it be more simple?
(Thanks for the Dukes)
Piet

Similar Messages

  • Why does my imessage not work with only 1 phone number

    Why does my imessage not work with only 1 phone number? It keeps going to imessage and then back to text message

    Both you and the recipient have to have active data connections, and both devices have to have iOS 5 or higher to be able to use iMessage. Also, they both have to have iMessage activated. If that is already the case, there is a possiblility that iMessage is down. It has gone up and down several times in the past week. Check this page for status, and if necessary you can report a problem with a link in the lower right corner. http://www.apple.com/support/icloud/systemstatus/

  • Why does flash player not work with facebook?

    Why does flash player not work with fcebook?  Whenever I wish to view a video, I get the message that i need to upgrade my flash player. Then no matter how often I download and install flash player I still get the message that I need to upgrade my flash player.  When I go check which version I have, I always get the message that I have the most current one.  I run Mozilla Firefox with Windows.  I don't know anything else.
    Message was edited by: khettich

    This means you don't have the latest version installed.  Update to 11.9.900.117, and Firefox will allow it: Flash Player Plug-in (All other browsers)

  • Why does Java Application not working with Macromedia Flash 5 or MX?

    Why does Java Application not working with Macromedia Flash 5 or MX?

    Who says they don't?
    Although I don't know much about those I'd think they should be able to talk to Java Aps using Sockets or request Servlets ...
    Spieler

  • HT4759 Why does icloud Contacts not work with Windows XP?

    Does anybody know why iCloud  Web page does not work with  Windows XP? I  have tried IE, Firefox and Chrome 

    XP is not supported by iCloud, that's why.
    iCloud System Requirements. PC.
    Microsoft Windows 7 or 8
    iCloud Control Panel 2.1 or later
    iTunes 11 or later (for iTunes in the Cloud and iTunes Match)
    Outlook 2007 or 2010 or iCloud.com
    Safari 5.1.7 or later or Internet Explorer 9 or later (for iCloud.com and Bookmarks), Firefox 16 or later or Chrome 23 or later (for iCloud.com)

  • Why does Server Monitor not work with non-Xserves?

    Does anyone know why Server Monitor does not work with non-Xserve computers? We acquired a Power Mac for a server, based on there being no apparent difference except for the obvious. Turns out there are some differences after all.
    Do Power Macs lack some hardware components or is this just a software thing?

    God question, unfortunitly I dont have the answer but I would also like to know why the software only works for X-Serve....Is there any 3rd Party Software that is similar to "Server Monitor"?
    Thanks

  • Why does Apogee Jam not work with the Ipod Touch 4G

    Hi,
    I have a Apogge Jam an it works fine with my Mac Book, but it does not seem to be compatible with my Ipod Touch 4g.
    Only the Gibbson L&M app recognize the Apogee Jam, but no other App (Ampkit, ....) :-((
    With the IPhone 4 it shall work, can tell me anybody why Apogee Jam is not compatible with the Ipod Touch 4g (
    although the Gibson-App works)?
    Is there perhaps still other Apps which work with the Ipod Touch and Apogge Jam?
    Thanks
    Michael

    I cannot answer the specifics, but I would guess it is a software issue because Griffin iTalk app will cooperate with the Apogee JAM on an iPod Touch 4g running iOS5.  If this app can do it, then one would presume the other apps could be updated to do it also.
    From last week up until yesterday, Apogee actually listed the 4G Touch as a compatible device with the JAM.
    Apparently there was some confusion about Garageband now supporting iPod Touch and its functionality with JAM.

  • Why does my webcam not work with Skype - can anyone help?

    Why does my webcam on Mac Book air not work with Skype - can anyone help?

    Did you set the Skype Audio/Video preferences to use the camera?

  • Why does Google Search not work with FF14.0.1?

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/934886]]</blockquote>
    When I use Google Search, no matter what I type in, this is all that shows up:
    http://i20.photobucket.com/albums/b232/emerald_typhoon/Example1.jpg
    If I use Google Images, the search results and suggestions will show up:
    http://i20.photobucket.com/albums/b232/emerald_typhoon/Example2.jpg
    If I click on Search along the top to go back to search after using Images, the web results will be displayed. I'm not sure what's wrong, as it only does it with Fire Fox. I've checked with other browsers, and Google still works with them. Does anyone have any idea what could be doing this?

    Did you try to clear the Google cookies?
    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    You can also do a malware check with some malware scanning programs on the Windows computer.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br /><br />
    *http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    *http://www.superantispyware.com/ - SuperAntispyware
    *http://www.microsoft.com/security/scanner/en-us/default.aspx - Microsoft Safety Scanner
    *http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    *http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    You can also do a check for a rootkit infection with TDSSKiller.
    *http://support.kaspersky.com/viruses/solutions?qid=208280684
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Why does Google Chat not work with Firefox v9.0

    When I use Internet Explorer 8.0/7601 Go0gleTalk works fine.
    However, when I use Firefox I get the message that the contact I want to talk to is offline. I can see that they are online in IE8 But, on this computer it does not work. On my Laptop all is well. What can I do please?

    Did you try to clear the Google cookies?
    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    You can also do a malware check with some malware scanning programs on the Windows computer.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br /><br />
    *http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    *http://www.superantispyware.com/ - SuperAntispyware
    *http://www.microsoft.com/security/scanner/en-us/default.aspx - Microsoft Safety Scanner
    *http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    *http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    You can also do a check for a rootkit infection with TDSSKiller.
    *http://support.kaspersky.com/viruses/solutions?qid=208280684
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Why does animated .gif not work with windows?

    I have created an animated .gif to place in a powerpoint presentation, but when I sent it to my client who used a windows computer, it does not work. When I try to open the .gif in my windows 98 virtual machine, it says it has errors.
    I created it in photoshop CC using the timeline and saving it with "save for web".

    AAAAAAAGGGGGGHHH!  Stupid Powerpoint corrupted the files when it "packaged" them
    Thank you for pointing me in the right direction.
    It is very difficult to figure out what my client is doing on his end.
    It won't let me mark you both as correct.

  • Why does snaps pro not work with mountain lion?

    I spent a lot money purchasing the pro addition only to be told that it won't work with mountain lion due to Apple's written something into the code that does not permit me to make videos with it. I even tried ot make a video of Indesign acting up so i could send it to Adobe support and it wouldn't allow me to. Is this the resaon it suddenly doesn't work anymore? Are there plans to fix mountian lion to allow me to use my software? Alternatively,, does Apple have something that does screen captures of videos?

    this is the repsonse form Ambrosia: (Not sure I understand it)
    As far as Snapz Pro X 2 functionality, some major backend Digital Rights Management changes enacted by Apple may be what is preventing you from recording movies you were previously able to record using our software. Basically, our program can no longer access videos before the DRM protections are enabled, unfortunately we have no control over these changes. Please see the following FAQ:http://www.ambrosiasw.com/support/faqs/products/snapz-pro-x /Why-does-the-content-of-my-capture-display-as-a-checkerboard
    BTW I am current on the latgest version.
    Does anybody know how to work around my problem? I need to be able to record videos on my computer.

  • Why does my imessage not work with some phones

    Its come to my attention that with some Iphone 4s and Iphone 5 users my imessage as well as facetime does not work. Why is this?

    LilEther wrote:
    Why is this?
    How would we know?  We're not in possession of their or your phone to troubleshoot or see how it's configured.

  • Why does my network not work with both computers

    Why do we each have to reconfigure the network every time we use our computers?

    What is the exact problem? Is it that your current network does not support providing Internet access to more than one computer at a time? Regardless, what is the make & model of your network's router and modem? If your network has more than one router, what is the make & models of each of them and how are they configured?

  • Why does itunes 7 not work with my ipod!?

    I am able to oberlook the fact that whenever i plug my 60 gb ipod colour into a pc it doesnt work, and often messes up the pc.
    But why do i now find that when i plug it into my own pc it wont work with itunes 7, when i googled this problem it seemed ALOT of other people have similar problems, if this is true why has nothing been done??? and why did apple even release this version of itunes if it doesnt work?!
    Please please please resolve this or tell me a way i can fix it.
    I have tried installing older versions of itunes but my ipod just wont work with them, and when i try to restore it it says that my ipod cannot be restored or isnt supported by this application.
    I cannot be the only person to think that someone seriously dropped the ball here.
    Please help!

    I've also tried uninstalling iTunes and everything iPod related - then reinstalled everything...still my iPod will not connect to iTunes. Oh and by-the-way, uninstalling iTunes (suck-eggs) 7.0 and then installing iTunes 6.0 will not work because once you install the SUCK-EGGS version, an older version can not read the libraries and therefore can not open! Who said Apple doesn't create PC-like operational blackholes?!?!? Someone please help! I'm gonna call Apple...I'll keep you posted.

Maybe you are looking for