Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37034
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: What's the best way to make a cross string set? |
| Date | 2017-07-31 12:01 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <olnk1i$sc7$1@dont-email.me> (permalink) |
| References | <6f9ff338-1944-4b64-83b8-4a921ce57a89@googlegroups.com> <olfv7c$8l3$3@Gaia.teknon.de> <d4c8c823-5603-4b80-be33-629d8d307faf@googlegroups.com> <olg9jv$8ct$1@dont-email.me> <1c3dafe0-c2ed-4ea1-9c06-b069f20c16ea@googlegroups.com> |
On 7/31/2017 8:24 AM, Eric Douglas wrote:
> On Friday, July 28, 2017 at 5:21:09 PM UTC-4, Eric Sosman wrote:
>> ArrayList list1 = new ArrayList()
>> should have been something like
>> List<List<String>> list1 = new ArrayList<>();
>> or
>> List<Collection<String>> list1 = new ArrayList<>();
>> or even
>> List<Iterable<String>> list1 = new ArrayList<>();
>> and
>> ArrayList list2 = new ArrayList()
>> should have been
>> List<String> list2 = new ArrayList<>();
>> or maybe
>> Collection<String> list2 = new ArrayList<>();
>> ... and, of course, other variations are possible.
>>
>
> You're saying declaring a variable as a List is more efficient even if you know it's going to be instantiated as ArrayList?
No, I did not say that, nor anything remotely like it. I won't
re-hash the pros and cons of declaring interface types vs. concrete
types, as they are probably covered in the instructional materials
you skimmed too hastily. (I've mentioned before that you exhibit a
strange combination of sophistication and ignorance, and I surmise
that your extensive experience with other programming languages may
have led you to short-change your Java studies and jump right in --
and find yourself in over your head.)
What I *did* say is that it is *better* (not "more efficient") to
declare List<String> (or ArrayList<String>, if you prefer) than raw
ArrayList. If you do not know why, go back to the books.
> I've always tried to avoid that because it's one more line in the import section, and I never use * imports because that just sounds confusing at best messy at worst when you get into the same class names in multiple packages.
The pros and cons of interface vs. concrete declaration are, as
I said, well-known to anyone who has given Java even a moderate
degree of attention. Go thou, and so do.
--
esosman@comcast-dot-net.invalid
Twelve hundred sixty-nine days to go.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-27 12:12 -0700
Re: What's the best way to make a cross string set? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-07-27 14:38 -0500
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-27 12:49 -0700
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-27 15:49 -0400
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-27 12:55 -0700
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-27 13:22 -0700
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-27 13:30 -0700
Re: What's the best way to make a cross string set? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-07-27 15:34 -0500
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-27 18:27 -0400
Re: What's the best way to make a cross string set? lewbloch@gmail.com - 2017-07-28 18:51 -0700
Re: What's the best way to make a cross string set? v_borchert@despammed.com (Volker Borchert) - 2017-07-29 06:03 +0000
Re: What's the best way to make a cross string set? v_borchert@despammed.com (Volker Borchert) - 2017-07-28 18:19 +0000
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-28 13:28 -0700
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-28 17:20 -0400
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-31 05:24 -0700
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-31 12:01 -0400
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-31 10:58 -0700
Re: What's the best way to make a cross string set? Sebastian <nowhere@nirvana.org> - 2017-07-31 18:13 +0200
Re: What's the best way to make a cross string set? lewbloch@gmail.com - 2017-07-31 09:24 -0700
Re: What's the best way to make a cross string set? Arne Vajhøj <arne@vajhoej.dk> - 2017-07-31 19:24 -0400
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-01 06:36 -0700
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-01 10:58 -0400
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-01 08:09 -0700
Re: What's the best way to make a cross string set? lewbloch@gmail.com - 2017-08-01 09:39 -0700
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-01 10:18 -0700
Re: What's the best way to make a cross string set? Andreas Leitgeb <avl@logic.at> - 2017-08-02 09:22 +0000
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-02 05:13 -0700
Re: What's the best way to make a cross string set? Andreas Leitgeb <avl@logic.at> - 2017-08-03 14:33 +0000
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-03 08:51 -0700
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-03 12:20 -0400
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-03 10:15 -0700
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-03 13:42 -0400
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-03 11:17 -0700
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-05 16:08 -0400
Re: What's the best way to make a cross string set? Martin Gregorie <martin@address-in-sig.invalid> - 2017-08-05 20:31 +0000
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-05 17:25 -0400
Re: What's the best way to make a cross string set? Martin Gregorie <martin@address-in-sig.invalid> - 2017-08-05 22:11 +0000
Re: What's the best way to make a cross string set? Sebastian <nowhere@nirvana.org> - 2017-08-06 18:13 +0200
Re: What's the best way to make a cross string set? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-02 12:56 -0700
Re: What's the best way to make a cross string set? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-29 16:55 -0400
Re: What's the best way to make a cross string set? Sebastian <nowhere@nirvana.org> - 2017-07-29 23:56 +0200
csiph-web