Comments on: Java for .net-guys or foreach in Java https://www.ticklishtechs.net/2009/04/28/java-for-net-guys-or-foreach-in-java/ a mostly .NET but also some other cool techs blog Thu, 13 Aug 2020 18:46:34 +0000 hourly 1 https://wordpress.org/?v=5.7.11 By: Kris https://www.ticklishtechs.net/2009/04/28/java-for-net-guys-or-foreach-in-java/comment-page-1/#comment-7964 Wed, 06 Jan 2010 20:12:28 +0000 http://www.ticklishtechs.net/2009/04/28/java-for-net-guys-or-foreach-in-java/#comment-7964 just stumbled upon this page as I was looking for a simpler way to do this (and also figure out the ‘getIterator’ vs ‘iterator’ business), and you’ve given a great way. Thanks! I’m a .NET guy normally so I’ll be giving your blog a good read!

]]>
By: Benjamin Schröter https://www.ticklishtechs.net/2009/04/28/java-for-net-guys-or-foreach-in-java/comment-page-1/#comment-3627 Wed, 29 Apr 2009 09:08:15 +0000 http://www.ticklishtechs.net/2009/04/28/java-for-net-guys-or-foreach-in-java/#comment-3627 @Arne: That makes sense. In .net (and my mind) the convention is exactly the other way: Properties are .net constructs and do not need a prefix for getter and setters. But when you have to do a lot of work to provide some date you will call the method GetSomething() instead of using a Something-property.

]]>
By: Arne https://www.ticklishtechs.net/2009/04/28/java-for-net-guys-or-foreach-in-java/comment-page-1/#comment-3621 Wed, 29 Apr 2009 06:35:32 +0000 http://www.ticklishtechs.net/2009/04/28/java-for-net-guys-or-foreach-in-java/#comment-3621 About the iterator() vs. getIterator() issue: as I understand it I’d say that getters are meant to be used for “fetching” properties of an object (for JavaBeans its even specified this way in the JavaBeans spec), i.e. getPort() on a java.net.URL returns its port as an integer. Iterators in contrast are not a property, but a different interface to access a collection, thus you can’t just fetch “the iterator” of a collection, there’s some code involved in creating it, and there might by more than one for each collection. The size of a collection (returned by size()) is a similar case, since the size is derived from the contents of a collection.
But from my experience with code “out there” I’d say that this rule isn’t always followed very strictly.

]]>