java 1.5 foreach statement

Discussion in 'Java' started by hugo, Aug 12, 2004.

  1. hugo

    hugo Guest

    I was hoping that the expanded java 'for' statement would accept any
    class that had a method "Iterator iterator()". This doesn't seem to be
    the case. What types are accepted in the Iterator free for-loops?
    Subclasses of Collection<T>?

    thanks
     
    hugo, Aug 12, 2004
    #1
    1. Advertising

  2. hugo

    Big-boo-TAY Guest

    On 12 Aug 2004 14:35:21 -0700, (hugo) wrote:

    >I was hoping that the expanded java 'for' statement would accept any
    >class that had a method "Iterator iterator()". This doesn't seem to be
    >the case. What types are accepted in the Iterator free for-loops?
    >Subclasses of Collection<T>?


    The object has to implement the Iterable<T> interface.
     
    Big-boo-TAY, Aug 12, 2004
    #2
    1. Advertising

  3. hugo wrote:

    > I was hoping that the expanded java 'for' statement would accept any
    > class that had a method "Iterator iterator()". This doesn't seem to be
    > the case. What types are accepted in the Iterator free for-loops?
    > Subclasses of Collection<T>?
    >
    > thanks


    Any object that implements Iterable:

    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Iterable.html

    --
    Kind regards,
    Christophe Vanfleteren
     
    Christophe Vanfleteren, Aug 12, 2004
    #3
  4. hugo

    Anony! Guest

    Any Java books out that teaches 1.5 concepts?

    AAA

    "Christophe Vanfleteren" <> wrote in message
    news:64SSc.212193$-ops.be...
    > hugo wrote:
    >
    > > I was hoping that the expanded java 'for' statement would accept any
    > > class that had a method "Iterator iterator()". This doesn't seem to be
    > > the case. What types are accepted in the Iterator free for-loops?
    > > Subclasses of Collection<T>?
    > >
    > > thanks

    >
    > Any object that implements Iterable:
    >
    > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Iterable.html
    >
    > --
    > Kind regards,
    > Christophe Vanfleteren



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
     
    Anony!, Aug 13, 2004
    #4
  5. hugo

    Liz Guest

    http://www.oreilly.com/catalog/javaadn/

    So how come you can't google yourself?


    "Anony!" <> wrote in message
    news:WlVSc.54519$...
    > Any Java books out that teaches 1.5 concepts?
    >
    > AAA
    >
    > "Christophe Vanfleteren" <> wrote in message
    > news:64SSc.212193$-ops.be...
    > > hugo wrote:
    > >
    > > > I was hoping that the expanded java 'for' statement would accept any
    > > > class that had a method "Iterator iterator()". This doesn't seem to be
    > > > the case. What types are accepted in the Iterator free for-loops?
    > > > Subclasses of Collection<T>?
    > > >
    > > > thanks

    > >
    > > Any object that implements Iterable:
    > >
    > > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Iterable.html
    > >
    > > --
    > > Kind regards,
    > > Christophe Vanfleteren

    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
    >
    >
     
    Liz, Aug 13, 2004
    #5
  6. hugo

    Anony! Guest

    I want someone to recommend me a book because they have direct experience
    with using it.

    AAA

    "Liz" <> wrote in message
    news:gFVSc.294790$Oq2.130280@attbi_s52...
    > http://www.oreilly.com/catalog/javaadn/
    >
    > So how come you can't google yourself?
    >
    >
    > "Anony!" <> wrote in message
    > news:WlVSc.54519$...
    > > Any Java books out that teaches 1.5 concepts?
    > >
    > > AAA
    > >
    > > "Christophe Vanfleteren" <> wrote in message
    > > news:64SSc.212193$-ops.be...
    > > > hugo wrote:
    > > >
    > > > > I was hoping that the expanded java 'for' statement would accept any
    > > > > class that had a method "Iterator iterator()". This doesn't seem to

    be
    > > > > the case. What types are accepted in the Iterator free for-loops?
    > > > > Subclasses of Collection<T>?
    > > > >
    > > > > thanks
    > > >
    > > > Any object that implements Iterable:
    > > >
    > > > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Iterable.html
    > > >
    > > > --
    > > > Kind regards,
    > > > Christophe Vanfleteren

    > >
    > >
    > > ---
    > > Outgoing mail is certified Virus Free.
    > > Checked by AVG anti-virus system (http://www.grisoft.com).
    > > Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
    > >
    > >

    >
    >



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
     
    Anony!, Aug 13, 2004
    #6
  7. hugo

    Liz Guest

    But you sez "any java books out.."
    you didn't ask for recom..


    "Anony!" <> wrote in message
    news:FNVSc.54535$...
    > I want someone to recommend me a book because they have direct experience
    > with using it.
    >
    > AAA
    >
    > "Liz" <> wrote in message
    > news:gFVSc.294790$Oq2.130280@attbi_s52...
    > > http://www.oreilly.com/catalog/javaadn/
    > >
    > > So how come you can't google yourself?
    > >
    > >
    > > "Anony!" <> wrote in message
    > > news:WlVSc.54519$...
    > > > Any Java books out that teaches 1.5 concepts?
    > > >
    > > > AAA
    > > >
    > > > "Christophe Vanfleteren" <> wrote in message
    > > > news:64SSc.212193$-ops.be...
    > > > > hugo wrote:
    > > > >
    > > > > > I was hoping that the expanded java 'for' statement would accept

    any
    > > > > > class that had a method "Iterator iterator()". This doesn't seem

    to
    > be
    > > > > > the case. What types are accepted in the Iterator free for-loops?
    > > > > > Subclasses of Collection<T>?
    > > > > >
    > > > > > thanks
    > > > >
    > > > > Any object that implements Iterable:
    > > > >
    > > > > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Iterable.html
    > > > >
    > > > > --
    > > > > Kind regards,
    > > > > Christophe Vanfleteren
    > > >
    > > >
    > > > ---
    > > > Outgoing mail is certified Virus Free.
    > > > Checked by AVG anti-virus system (http://www.grisoft.com).
    > > > Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
    > > >
    > > >

    > >
    > >

    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
    >
    >
     
    Liz, Aug 13, 2004
    #7
  8. hugo

    Anony! Guest

    my bad. sorry.

    AAA

    "Liz" <> wrote in message
    news:eXVSc.138838$eM2.14923@attbi_s51...
    > But you sez "any java books out.."
    > you didn't ask for recom..
    >
    >
    > "Anony!" <> wrote in message
    > news:FNVSc.54535$...
    > > I want someone to recommend me a book because they have direct

    experience
    > > with using it.
    > >
    > > AAA
    > >
    > > "Liz" <> wrote in message
    > > news:gFVSc.294790$Oq2.130280@attbi_s52...
    > > > http://www.oreilly.com/catalog/javaadn/
    > > >
    > > > So how come you can't google yourself?
    > > >
    > > >
    > > > "Anony!" <> wrote in message
    > > > news:WlVSc.54519$...
    > > > > Any Java books out that teaches 1.5 concepts?
    > > > >
    > > > > AAA
    > > > >
    > > > > "Christophe Vanfleteren" <> wrote in message
    > > > > news:64SSc.212193$-ops.be...
    > > > > > hugo wrote:
    > > > > >
    > > > > > > I was hoping that the expanded java 'for' statement would accept

    > any
    > > > > > > class that had a method "Iterator iterator()". This doesn't seem

    > to
    > > be
    > > > > > > the case. What types are accepted in the Iterator free

    for-loops?
    > > > > > > Subclasses of Collection<T>?
    > > > > > >
    > > > > > > thanks
    > > > > >
    > > > > > Any object that implements Iterable:
    > > > > >
    > > > > > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Iterable.html
    > > > > >
    > > > > > --
    > > > > > Kind regards,
    > > > > > Christophe Vanfleteren
    > > > >
    > > > >
    > > > > ---
    > > > > Outgoing mail is certified Virus Free.
    > > > > Checked by AVG anti-virus system (http://www.grisoft.com).
    > > > > Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >
    > > ---
    > > Outgoing mail is certified Virus Free.
    > > Checked by AVG anti-virus system (http://www.grisoft.com).
    > > Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
    > >
    > >

    >
    >



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004
     
    Anony!, Aug 13, 2004
    #8
  9. hugo

    Jim Guest

    On Sat, 14 Aug 2004 05:27:08 +0200, Morten Alver
    <morten@no_spam.boblefisk.org> wrote:

    >Anony! wrote:
    >> my bad. sorry.
    >>

    >
    >But why the top-posting? See the faq:
    >
    >A: Because it messes up the order in which people normally read text.
    >Q: Why is top-posting such a bad thing?
    >A: Top-posting.
    >Q: What is the most annoying thing on Usenet and in e-mail?


    Just one observation about top posting. The only reason I can see
    for not top posting is if you are still reading your news using
    telnet where the old stuff scrolls off the screen leaving the
    newest on the screen after scrolling!

    All those on this group still reading with telnet raise their hand!

    I post "correctly" because to do otherwise makes some folks unhappy
    but really, how many people like having to scroll to the end of every
    message before they can read it?

    Jim
     
    Jim, Aug 16, 2004
    #9
  10. hugo

    BigbooTAY Guest

    On Mon, 16 Aug 2004 01:50:37 GMT, Jim <> wrote:

    >I post "correctly" because to do otherwise makes some folks unhappy
    >but really, how many people like having to scroll to the end of every
    >message before they can read it?


    Same here, but I'm getting sick of knuckling under to the style
    bullies. I'm bottom-posting right now becuase I want to emphasize
    that I'm responding to a particular part of the prior message. But
    when I'm just including the OP's question for reference, it makes more
    sense to put it at the end. Rigid adherence to the no-top-posting
    rule makes for a worse Usenet experience on the whole, not a better
    one.
     
    BigbooTAY, Aug 16, 2004
    #10
  11. hugo

    Oscar kind Guest

    On top posting (was: Re: java 1.5 foreach statement)

    Jim <> wrote:
    > Just one observation about top posting. The only reason I can see
    > for not top posting is if you are still reading your news using
    > telnet where the old stuff scrolls off the screen leaving the
    > newest on the screen after scrolling!


    Another reason is that some don't read news in batches; If you read news in
    batches, it's easier to have the reply on top because the previous
    messages are easy to recall.

    On the other hand, if you read news regularly, I find it's easy to lose
    track of a conversation if top posting is used. In this case, quoting and
    replying to the quoted text is far better IMHO. Of course, if people don't
    take the time to trim what they quote, it's advantage degrades to "a bit
    better".


    > I post "correctly" because to do otherwise makes some folks unhappy
    > but really, how many people like having to scroll to the end of every
    > message before they can read it?


    I don't, but I do strongly dislike top posting: I don't want to scroll
    down to see the context of the message. After all, it's possible that the
    reply is about part of the parent message.

    Something I see happening regularly here, is replying to specific portions
    of a port. This is hardly possible with top posting, as you can only refer
    to the entire post. It's much better to post several replies, and in each
    reply only quote what you're replying to.

    Another thing I see happening regularly with top posting is that people
    don't take the time to trim the quoted part. Thus each followup message
    gets larger and larger, wasting bandwidth.


    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
     
    Oscar kind, Aug 16, 2004
    #11
  12. to left, why shouldn't bottom to top be an alternative?
    I like to call them. Japanese and many other cultures read from right
    formatted for the benefit of "top-posters", or "bottop-up readers" as
    bottom to get the flow of a conversation; this article is therefore
    That said, I will not force the culture of reading text from top to
    "backward".
    client that lets the user create responses in the natural way as
    browser's bad ways, and attacking anyone who uses a well-behaved
    change it, and instead spend their resources defending their
    default behaviour in Outlook Express, and people do not know how to
    because it's natural; top-posting is used simply because it's the
    Quoting relevant parts and adding your comments underneath it is used
    the (often fully quoted) article are you actually responding to?
    the flow of conversation. After all, with top-posting, which part of
    That is simply wrong; any news client can easily scroll down to reveal

    > newest on the screen after scrolling!
    > telnet where the old stuff scrolls off the screen leaving the
    > for not top posting is if you are still reading your news using
    > Just one observation about top posting. The only reason I can see


    Jim <> writes:
     
    Tor Iver Wilhelmsen, Aug 16, 2004
    #12
  13. hugo

    Chris Uppal Guest

    Reading upwards [was: java 1.5 foreach statement]

    Tor Iver Wilhelmsen wrote:

    > to left, why shouldn't bottom to top be an alternative?
    > I like to call them. Japanese and many other cultures read from right
    > formatted for the benefit of "top-posters", or "bottop-up readers" as
    > bottom to get the flow of a conversation; this article is therefore
    > That said, I will not force the culture of reading text from top to
    > "backward".
    > client that lets the user create responses in the natural way as
    > browser's bad ways, and attacking anyone who uses a well-behaved
    > change it, and instead spend their resources defending their
    > default behaviour in Outlook Express, and people do not know how to
    > because it's natural; top-posting is used simply because it's the
    > Quoting relevant parts and adding your comments underneath it is used
    > the (often fully quoted) article are you actually responding to?
    > the flow of conversation. After all, with top-posting, which part of
    > That is simply wrong; any news client can easily scroll down to reveal


    [OT, not continuing the joke, and quoted in full becase, well, I wanted to...]

    Does anyone else find that it's a lot harder to read the words /in/ each line
    when the lines are oddly arranged, even though the words themselves are in the
    normal order ?

    -- chris
     
    Chris Uppal, Aug 16, 2004
    #13
  14. hugo

    Jim Guest

    On 16 Aug 2004 10:32:55 +0200, Tor Iver Wilhelmsen
    <> wrote:

    >
    >to left, why shouldn't bottom to top be an alternative?
    >I like to call them. Japanese and many other cultures read from right
    >formatted for the benefit of "top-posters", or "bottop-up readers" as
    >bottom to get the flow of a conversation; this article is therefore
    >That said, I will not force the culture of reading text from top to
    >"backward".
    >client that lets the user create responses in the natural way as
    >browser's bad ways, and attacking anyone who uses a well-behaved
    >change it, and instead spend their resources defending their
    >default behaviour in Outlook Express, and people do not know how to
    >because it's natural; top-posting is used simply because it's the
    >Quoting relevant parts and adding your comments underneath it is used
    >the (often fully quoted) article are you actually responding to?
    >the flow of conversation. After all, with top-posting, which part of
    >That is simply wrong; any news client can easily scroll down to reveal
    >
    >> newest on the screen after scrolling!
    >> telnet where the old stuff scrolls off the screen leaving the
    >> for not top posting is if you are still reading your news using
    >> Just one observation about top posting. The only reason I can see

    >
    >Jim <> writes:


    OAMLFTOR

    Jim
     
    Jim, Aug 16, 2004
    #14
  15. hugo

    FISH Guest

    Jim <> wrote in message news:<>...
    [snipped...]

    > Just one observation about top posting. The only reason I can see
    > for not top posting is if you are still reading your news using
    > telnet where the old stuff scrolls off the screen leaving the
    > newest on the screen after scrolling!


    Just because you cannot think of a valid reason, does not mean that
    there is none. You've missed the most obvious reason for not
    adopting top-posting as a 'standard' (or convention).


    > All those on this group still reading with telnet raise their hand!


    Oh you'd be surprised... :)


    > I post "correctly" because to do otherwise makes some folks unhappy
    > but really, how many people like having to scroll to the end of every
    > message before they can read it?


    Now, you may have notived two strange phenomena in my reply to you.
    Firstly, I snipped a large body of text from the top of the message,
    and secondly I interleaved my comments in between yours to make the
    discussion actually work as a dialogue.

    The first top-posters rarely do (due to the very nature of top-posting)
    and the second they *cannot* do.

    Interleaved discussion like this is generally far more readable,
    particularly in involved discussions . It keeps comment and reply
    together, and thereby eliminates ambiguity and cumbersome flipping up
    and down to consult both texts. In short: it creates a living
    breathing transcript, as opposed to an array of disembodied comments.

    Now before you attempt to savage me in some pro/anti-top-posting
    flame war, can I point out that I often think some people on Usenet
    are far far too quick to jump down other people's throats for the
    slightest indiscretion. I've lost count of the number of newbie's
    here who have been met with one useful answer to their question, and
    half a dozen snotty replies about their poor Netiquette. I sometimes
    wonder if there are a body of Usenet posters out there who do nothing
    but search out and flame other uses for any breach of 'the rules'...
    still if that's how you get your kicks then... :-(

    That said, top posting is something which should be discouraged.
    Oh, it's fine if all you ever plan to contribute is a short
    paragraph... if that's the sum total of your worth then top-posting
    will serve you well. But the problem is this... **it doesn't scale
    well!** And it is due to this total lack of scalabilty when a
    discussion really takes off that it should, out of respect for
    other's who want to have *serious/involved* exchanges, be avoided.


    -FISH- ><>
     
    FISH, Aug 17, 2004
    #15
  16. hugo

    Jim Guest

    On 17 Aug 2004 09:21:30 -0700, (FISH) wrote:

    >Jim <> wrote in message news:<>...
    >[snipped...]
    >
    >
    >> All those on this group still reading with telnet raise their hand!

    >
    >Oh you'd be surprised... :)
    >

    Which is why I asked.

    <snip>
    >Now, you may have notived two strange phenomena in my reply to you.
    >Firstly, I snipped a large body of text from the top of the message,
    >and secondly I interleaved my comments in between yours to make the
    >discussion actually work as a dialogue.

    And yes I snip quite often.

    >Now before you attempt to savage me in some pro/anti-top-posting
    >flame war, can I point out that I often think some people on Usenet
    >are far far too quick to jump down other people's throats for the
    >slightest indiscretion.


    At this point I will not start a "Butter Battle"

    And since this thread has moved considerably away from
    the java 1.5 for statement I close.........

    Jim

    "Whenever the locals rub blue mud in their navels,
    I rub blue mud in mine just as solemnly."

    "Time Enough For Love", Robert Heinlein
     
    Jim, Aug 18, 2004
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    817
  2. Replies:
    1
    Views:
    21,213
  3. Jay McGavren
    Replies:
    11
    Views:
    1,159
    Alan Krueger
    Jan 16, 2006
  4. tedsuzman
    Replies:
    2
    Views:
    7,128
    Michel Claveau, résurectionné d'outre-bombe inform
    Jul 21, 2004
  5. xyoavx

    foreach statement's parentheses

    xyoavx, Dec 4, 2005, in forum: Perl Misc
    Replies:
    11
    Views:
    182
    xyoavx
    Dec 7, 2005
Loading...

Share This Page