Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34365
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: how does one explain this syntax? |
| Date | Sun, 22 May 2016 07:21:15 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 57 |
| Message-ID | <nhs4gm$lre$1@dont-email.me> (permalink) |
| References | <nhrhd5$7r6$1@reader1.panix.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Sun, 22 May 2016 11:17:42 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="2d081e2f7155c28005d4472f67c2f43d"; logging-data="22382"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2+k+WDjUf8CD1R9wK6UJ7" |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 |
| In-Reply-To | <nhrhd5$7r6$1@reader1.panix.com> |
| Cancel-Lock | sha1:hhQZe24thJNrfdkxlm78jkK2Njk= |
| Xref | csiph.com comp.lang.java.programmer:34365 |
Show key headers only | View raw
On 5/22/2016 1:51 AM, ruben safir wrote:
> This passes for a demonstration and teaching example for a TreeMap
Until somebody added uncompilable junk to it, perhaps.
> import java.util.TreeMap;
> import java.util.Set;
> import java.util.Iterator;
> import java.util.Map;
>
> public class Details {
>
> public static void main(String args[]) {
>
> /* This is how to declare TreeMap */
> TreeMap<Integer, String> tmap =
> new TreeMap<Integer, String>(); <<studdering is always good
Not sure what you mean here.
> /*Adding elements to TreeMap*/
> tmap.put(1, "Data1");
> tmap.put(23, "Data2");
> tmap.put(70, "Data3");
> tmap.put(4, "Data4");
> tmap.put(2, "Data5");
>
> /* Display content using Iterator*/
> Set set = tmap.entrySet(); <<random obscure syntax... that is a
> constructor for another class?
It's a method call.
> Iterator iterator = set.iterator(); <<again, twice?
It's a method call.
> while(iterator.hasNext()) {
> Map.Entry mentry = (Map.Entry)iterator.next(); <<What the heck
> is this?
It's a method call, with a cast applied to the returned value.
> System.out.print("key is: "+ mentry.getKey() + " & Value is:
> "); <<How many levels of random systax does one need to just to do a loop?
It's a method call, not something random and certainly not "systax."
> System.out.println(mentry.getValue());
> }
>
> }
> }
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how does one explain this syntax? ruben safir <ruben@mrbrklyn.com> - 2016-05-22 01:51 -0400
Re: how does one explain this syntax? Martin Gregorie <martin@address-in-sig.invalid> - 2016-05-22 10:05 +0000
Re: how does one explain this syntax? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-22 07:21 -0400
Re: how does one explain this syntax? Popping mad <rainbow@colition.gov> - 2016-05-22 20:21 +0000
Re: how does one explain this syntax? Lars Enderin <lars.enderin@telia.com> - 2016-05-22 22:32 +0200
Re: how does one explain this syntax? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-22 17:32 -0400
Re: how does one explain this syntax? Lew <lewbloch@gmail.com> - 2016-05-23 14:36 -0700
Re: how does one explain this syntax? Lew <lewbloch@gmail.com> - 2016-05-23 14:34 -0700
Re: how does one explain this syntax? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-05-22 08:41 -0700
Re: how does one explain this syntax? Robert Klemme <shortcutter@googlemail.com> - 2016-05-22 22:22 +0200
Re: how does one explain this syntax? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-05-22 22:13 -0700
Re: how does one explain this syntax? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-23 07:32 -0400
Re: how does one explain this syntax? Robert Klemme <shortcutter@googlemail.com> - 2016-05-23 04:57 -0700
Re: how does one explain this syntax? Popping mad <rainbow@colition.gov> - 2016-05-22 20:23 +0000
Re: how does one explain this syntax? Roedy Green <inquiry@mindprod.com> - 2016-05-30 21:51 -0700
Re: how does one explain this syntax? Roedy Green <inquiry@mindprod.com> - 2016-05-30 21:54 -0700
Re: how does one explain this syntax? Roedy Green <inquiry@mindprod.com> - 2016-05-30 22:00 -0700
Re: how does one explain this syntax? Roedy Green <inquiry@mindprod.com> - 2016-05-30 22:17 -0700
csiph-web