Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #23175 > unrolled thread
| Started by | subhabangalore@gmail.com |
|---|---|
| First post | 2013-04-02 03:11 -0700 |
| Last post | 2013-04-03 10:35 +0100 |
| Articles | 20 on this page of 161 — 18 participants |
Back to article view | Back to comp.lang.java.programmer
Inserting In a List subhabangalore@gmail.com - 2013-04-02 03:11 -0700
Re: Inserting In a List Roedy Green <see_website@mindprod.com.invalid> - 2013-04-02 03:59 -0700
Re: Inserting In a List Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-02 08:27 -0300
Re: Inserting In a List Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-02 08:59 -0300
Re: Inserting In a List Martin Gregorie <martin@address-in-sig.invalid> - 2013-04-02 21:06 +0000
Re: Inserting In a List Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-02 18:22 -0400
Re: Inserting In a List Martin Gregorie <martin@address-in-sig.invalid> - 2013-04-02 22:52 +0000
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-03 02:04 +0200
Re: Inserting In a List Arne Vajhøj <arne@vajhoej.dk> - 2013-04-02 20:20 -0400
Re: Inserting In a List Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-02 21:03 -0400
Re: Inserting In a List Arne Vajhøj <arne@vajhoej.dk> - 2013-04-02 21:26 -0400
Re: Inserting In a List Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-02 22:29 -0400
Re: Inserting In a List Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 20:16 -0400
Re: Inserting In a List Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2013-04-02 20:26 -0500
Re: Inserting In a List Arne Vajhøj <arne@vajhoej.dk> - 2013-04-02 21:29 -0400
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 14:07 +0200
Re: Inserting In a List Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-03 05:45 -0300
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-03 15:26 +0200
Re: Inserting In a List Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-03 18:09 -0300
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 00:54 +0200
Re: Inserting In a List Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-03 20:30 -0300
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 01:35 +0200
Re: Inserting In a List Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-03 20:55 -0300
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 02:00 +0200
Re: Inserting In a List Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 19:49 -0400
Re: Inserting In a List Martin Gregorie <martin@address-in-sig.invalid> - 2013-04-03 22:43 +0000
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 01:08 +0200
Re: Inserting In a List Martin Gregorie <martin@address-in-sig.invalid> - 2013-04-04 00:42 +0000
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 14:12 +0200
Re: Inserting In a List Martin Gregorie <martin@address-in-sig.invalid> - 2013-04-04 21:47 +0000
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-05 00:36 +0200
Re: Inserting In a List Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-02 21:08 -0400
Re: Inserting In a List Martin Gregorie <martin@address-in-sig.invalid> - 2013-04-03 22:37 +0000
Re: Inserting In a List Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-03 20:50 -0400
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-02 14:35 +0200
Re: Inserting In a List lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-02 15:08 +0100
Usefulness of "final" (Was: Re: Inserting In a List) Robert Klemme <shortcutter@googlemail.com> - 2013-04-02 21:06 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-02 16:41 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) Robert Klemme <shortcutter@googlemail.com> - 2013-04-03 08:09 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 20:13 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-02 20:08 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-03 11:15 +0100
Re: Usefulness of "final" (Was: Re: Inserting In a List) Robert Klemme <shortcutter@googlemail.com> - 2013-04-03 19:08 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-03 19:51 +0100
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-03 21:01 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 14:15 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 18:22 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 15:41 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 19:56 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 16:58 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 20:08 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 17:21 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 20:27 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 17:34 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-03 21:20 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 19:17 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Lew <lewbloch@gmail.com> - 2013-04-03 20:45 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 21:30 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 14:34 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-04 09:52 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-05 00:39 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) Robert Klemme <shortcutter@googlemail.com> - 2013-04-04 19:50 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-04 08:27 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-04 09:47 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Robert Klemme <shortcutter@googlemail.com> - 2013-04-04 19:44 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-04 11:08 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Robert Klemme <shortcutter@googlemail.com> - 2013-04-04 22:53 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-04 14:29 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Robert Klemme <shortcutter@googlemail.com> - 2013-04-05 21:54 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-04 19:48 +0100
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 20:05 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 17:24 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 20:32 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 18:34 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 21:54 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-03 21:25 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 18:37 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 21:57 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 19:23 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Wanja Gayk <brixomatic@yahoo.com> - 2013-04-06 21:58 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-06 17:19 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Wanja Gayk <brixomatic@yahoo.com> - 2013-04-07 17:28 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-07 09:02 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Wanja Gayk <brixomatic@yahoo.com> - 2013-04-07 19:20 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) Wanja Gayk <brixomatic@yahoo.com> - 2013-04-07 19:24 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) Lew <lewbloch@gmail.com> - 2013-04-03 18:41 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Lew <lewbloch@gmail.com> - 2013-04-03 18:31 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 18:46 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Lew <lewbloch@gmail.com> - 2013-04-03 20:09 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 20:47 -0700
Re: Usefulness of "final" Leif Roar Moldskred <leifm@dimnakorr.com> - 2013-04-04 00:42 -0500
Re: Usefulness of "final" paul.cager@gmail.com - 2013-04-04 01:55 -0700
Re: Usefulness of "final" Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 14:45 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 00:46 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 16:10 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 01:25 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 16:44 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 01:57 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 17:19 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 14:35 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-04 10:34 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-05 00:43 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-04 16:22 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Lew <lewbloch@gmail.com> - 2013-04-04 16:49 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-04 18:21 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Lew <lewbloch@gmail.com> - 2013-04-04 18:49 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-05 05:30 -0300
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arne Vajhøj <arne@vajhoej.dk> - 2013-04-03 20:10 -0400
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-03 17:29 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 02:53 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) Jim Janney <jjanney@shell.xmission.com> - 2013-04-04 13:51 -0600
Re: Usefulness of "final" (Was: Re: Inserting In a List) Robert Klemme <shortcutter@googlemail.com> - 2013-04-06 13:31 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) markspace <markspace@nospam.nospam> - 2013-04-06 10:50 -0700
Re: Usefulness of "final" (Was: Re: Inserting In a List) lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-04 09:09 +0100
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-04 05:37 -0300
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-04 06:10 -0300
Re: Usefulness of "final" (Was: Re: Inserting In a List) Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-04 19:40 -0300
Re: arrays and variables Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-05 05:44 -0300
Re: arrays and variables lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-05 14:08 +0100
Re: arrays and variables Lew <lewbloch@gmail.com> - 2013-04-05 13:33 -0700
Re: arrays and variables lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-06 09:11 +0100
Re: arrays and variables Robert Klemme <shortcutter@googlemail.com> - 2013-04-06 15:20 +0200
Re: arrays and variables lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-06 16:25 +0100
Re: arrays and variables Robert Klemme <shortcutter@googlemail.com> - 2013-04-06 17:50 +0200
Re: arrays and variables lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-06 18:13 +0100
Re: arrays and variables Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-06 14:32 -0300
Re: arrays and variables Robert Klemme <shortcutter@googlemail.com> - 2013-04-06 15:02 +0200
Re: arrays and variables Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-05 22:12 -0300
Re: Usefulness of "final" (Was: Re: Inserting In a List) lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-04 10:35 +0100
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 14:02 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-04 13:41 +0100
Re: Usefulness of "final" (Was: Re: Inserting In a List) Joerg Meier <joergmmeier@arcor.de> - 2013-04-04 13:53 +0200
Re: Usefulness of "final" (Was: Re: Inserting In a List) Robert Klemme <shortcutter@googlemail.com> - 2013-04-03 23:05 +0200
Re: Inserting In a List Joerg Meier <joergmmeier@arcor.de> - 2013-04-02 22:09 +0200
Re: Inserting In a List Arne Vajhøj <arne@vajhoej.dk> - 2013-04-02 20:03 -0400
Re: Inserting In a List Wanja Gayk <brixomatic@yahoo.com> - 2013-04-06 21:39 +0200
Re: Inserting In a List Robert Klemme <shortcutter@googlemail.com> - 2013-04-07 01:08 +0200
Re: Inserting In a List Lew <lewbloch@gmail.com> - 2013-04-06 22:15 -0700
Re: Inserting In a List lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-07 08:48 +0100
Re: Inserting In a List Lew <lewbloch@gmail.com> - 2013-04-07 12:32 -0700
Re: Inserting In a List "John B. Matthews" <nospam@nospam.invalid> - 2013-04-07 21:06 -0400
Re: Inserting In a List lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-08 08:40 +0100
Re: Inserting In a List lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-07 08:55 +0100
Re: Inserting In a List Wanja Gayk <brixomatic@yahoo.com> - 2013-04-07 17:54 +0200
Re: Inserting In a List lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-07 19:53 +0100
Re: Inserting In a List Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-07 17:58 -0300
Re: Inserting In a List Robert Klemme <shortcutter@googlemail.com> - 2013-04-08 08:28 +0200
Re: Inserting In a List lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-08 08:54 +0100
Re: Inserting In a List Robert Klemme <shortcutter@googlemail.com> - 2013-04-08 19:13 +0200
Re: Inserting In a List Wanja Gayk <brixomatic@yahoo.com> - 2013-04-12 20:58 +0200
Re: Inserting In a List Lew <lewbloch@gmail.com> - 2013-04-12 13:17 -0700
Re: Inserting In a List Lew <lewbloch@gmail.com> - 2013-04-07 12:40 -0700
Re: Inserting In a List Wanja Gayk <brixomatic@yahoo.com> - 2013-04-12 20:47 +0200
Re: Inserting In a List Lew <lewbloch@gmail.com> - 2013-04-12 13:14 -0700
Re: Inserting In a List Steven Simpson <ss@domain.invalid> - 2013-04-02 13:53 +0100
Re: Inserting In a List Roedy Green <see_website@mindprod.com.invalid> - 2013-04-02 07:10 -0700
Re: Inserting In a List Lew <lewbloch@gmail.com> - 2013-04-02 10:46 -0700
Re: Inserting In a List markspace <markspace@nospam.nospam> - 2013-04-02 11:28 -0700
Re: Inserting In a List Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-02 16:00 -0400
Re: Inserting In a List subhabangalore@gmail.com - 2013-04-03 01:47 -0700
Re: Inserting In a List Steven Simpson <ss@domain.invalid> - 2013-04-03 10:35 +0100
Page 7 of 9 — ← Prev page 1 2 3 4 5 6 [7] 8 9 Next page →
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-04-06 09:11 +0100 |
| Subject | Re: arrays and variables |
| Message-ID | <IoSdnUUnpq5NRcLMnZ2dnUVZ8qKdnZ2d@bt.com> |
| In reply to | #23342 |
On 05/04/13 21:33, Lew wrote: > lipska the kat wrote: >> Stefan Ram wrote: >>> Arved Sandstrom writes: >>>> Stefan Ram wrote: >>>>> Arved Sandstrom writes: >> >> [snip] >> >>> What is C? We have pointers in Java, see the JLS. >> >> Do we? I never knew that > > It's in the JLS, 4.3.1. > "An object is a class instance or an array. > > "The reference values (often just references) are pointers to these objects, > and a special null reference, which refers to no object." This is a rhetorical usage of the word pointer and says nothing about the underlying mechanism used to implement references. >> a pointer in C >> >> int x >> int *iptr; >> iptr = &x; >> iptr++; //stupid but not illegal >> >> How would I do that in Java using pointers (note the *pointer arithmatic*). > > Java does not have pointer arithmetic. You don't say :-| > It only has pointers for reference types Weasel words, I don't believe that you actually believe that. A reference is an abstraction of a pointer, this is an absolutely fundamental concept and any newbie lurkers take note *a reference is not a pointer*, it's a reference. *IF* a reference is implemented as a pointer under the covers then that is an implementation detail. It is hypothetically possible to implement Java as a Turing Machine, in this case a reference would not be a 'pointer' but a square on an infinite tape that might contain an instruction that instructs the machine how to interpret the next square on the tape. Is this square a pointer? What does a reference abstract? it abstracts the mechanism by which Java provides access to instances of classes, it abstracts the mechanism by which Java allocates space to store that instance and it provides the mechanism to populate the allocated space. Besides, a pointer without pointer arithmetic isn't a pointer (IMHO of course) :-) [snip] lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Date | 2013-04-06 15:20 +0200 |
| Subject | Re: arrays and variables |
| Message-ID | <asalosFhgmlU1@mid.individual.net> |
| In reply to | #23344 |
On 06.04.2013 10:11, lipska the kat wrote: > On 05/04/13 21:33, Lew wrote: >> lipska the kat wrote: >>> Stefan Ram wrote: >>>> Arved Sandstrom writes: >>>>> Stefan Ram wrote: >>>>>> Arved Sandstrom writes: >>> >>> [snip] >>> >>>> What is C? We have pointers in Java, see the JLS. >>> >>> Do we? I never knew that >> >> It's in the JLS, 4.3.1. >> "An object is a class instance or an array. >> >> "The reference values (often just references) are pointers to these >> objects, >> and a special null reference, which refers to no object." > > This is a rhetorical usage of the word pointer and says nothing about > the underlying mechanism used to implement references. Why "rhetorical"? You seem to imply that "pointer" and "memory address" are synonymous. But this is not necessarily the case even though personally I tend to also use it that way. <pssst>I think Lew enjoys it from time to time to prove someone wrong who claims there are no pointers in Java because it is often surprising for Java programmers to find that p-word in the JLS. :-)</pssst> >> It only has pointers for reference types > > Weasel words, I don't believe that you actually believe that. Why and why? There is nothing weaselish about quoting the JLS. Do you have a definition of the Java language with higher authority that does not contain the word "pointer"? > A reference is an abstraction of a pointer, [...] I think most people in software engineering actually use the terms the way you have presented them here which is also reflected in the article about pointers on wikipedia. That does not preclude other usages in specific context so the heads up of Lew is actually in order to keep us alert and use terms consciously. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-04-06 16:25 +0100 |
| Subject | Re: arrays and variables |
| Message-ID | <juqdnQx1-bb0o_3MnZ2dnUVZ8lidnZ2d@bt.com> |
| In reply to | #23347 |
On 06/04/13 14:20, Robert Klemme wrote: > On 06.04.2013 10:11, lipska the kat wrote: >> On 05/04/13 21:33, Lew wrote: >>> lipska the kat wrote: >>>> Stefan Ram wrote: >>>>> Arved Sandstrom writes: >>>>>> Stefan Ram wrote: >>>>>>> Arved Sandstrom writes: >>>> >>>> [snip] >>>> >>>>> What is C? We have pointers in Java, see the JLS. >>>> >>>> Do we? I never knew that >>> >>> It's in the JLS, 4.3.1. >>> "An object is a class instance or an array. >>> >>> "The reference values (often just references) are pointers to these >>> objects, >>> and a special null reference, which refers to no object." >> >> This is a rhetorical usage of the word pointer and says nothing about >> the underlying mechanism used to implement references. > > Why "rhetorical"? The Java Language Specification is just that, a specification. Constraining an implementation to use *pointers is not within the purview of the specification, this is why I suggested that the usage is rhetorical. > You seem to imply that "pointer" and "memory address" > are synonymous. In the context of this micro-discussion I'm explicitly stating the exact opposite. > But this is not necessarily the case even though > personally I tend to also use it that way. > > <pssst>I think Lew enjoys it from time to time to prove someone wrong > who claims there are no pointers in Java because it is often surprising > for Java programmers to find that p-word in the JLS. :-)</pssst> There are any number of articles and anecdotal references to the fact that the language designers explicitly declined to implement *pointers* in Java, any such references in the specification must therefore be considered rhetorical for the reasons stated above. >>> It only has pointers for reference types >> >> Weasel words, I don't believe that you actually believe that. > > Why Weasel words are ... words and phrases aimed at creating an impression that something specific and meaningful has been said. http://en.wikipedia.org/wiki/Weasel_word It is neither specific, Java does not have pointers, nor meaningful, nowhere in the specification does it say (I would guess) that references have to be implemented by *pointers > and why? There is nothing weaselish about quoting the JLS. I'd be very interested to see the line in the spec that says 'It [Java] only has pointers for reference types' Show me that and watch me eat my hat. > Do you > have a definition of the Java language with higher authority that does > not contain the word "pointer"? I should imagine a suitably equipped PhD student could do it in EBNF without once mentioning the word 'pointer' :-) >> A reference is an abstraction of a pointer, [...] > > I think most people in software engineering actually use the terms the > way you have presented them here which is also reflected in the article > about pointers on wikipedia. That does not preclude other usages in > specific context so the heads up of Lew is actually in order to keep us > alert and use terms consciously. Of course it is, how could I possibly imagine that it could ever be otherwise. Although ... actually, forget it, it really isn't that important, the sun is shining and I have seeds to sow, the lawn to cut and frogs to watch in the pond. ttfn lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Date | 2013-04-06 17:50 +0200 |
| Subject | Re: arrays and variables |
| Message-ID | <asauirFjg50U1@mid.individual.net> |
| In reply to | #23348 |
On 06.04.2013 17:25, lipska the kat wrote: > On 06/04/13 14:20, Robert Klemme wrote: >> On 06.04.2013 10:11, lipska the kat wrote: >>> On 05/04/13 21:33, Lew wrote: >>>> lipska the kat wrote: >>>>> Stefan Ram wrote: >>>>>> Arved Sandstrom writes: >>>>>>> Stefan Ram wrote: >>>>>>>> Arved Sandstrom writes: >>>>> >>>>> [snip] >>>>> >>>>>> What is C? We have pointers in Java, see the JLS. >>>>> >>>>> Do we? I never knew that >>>> >>>> It's in the JLS, 4.3.1. >>>> "An object is a class instance or an array. >>>> >>>> "The reference values (often just references) are pointers to these >>>> objects, >>>> and a special null reference, which refers to no object." >>> >>> This is a rhetorical usage of the word pointer and says nothing about >>> the underlying mechanism used to implement references. >> >> Why "rhetorical"? > > The Java Language Specification is just that, a specification. > Constraining an implementation to use *pointers is not within the > purview of the specification, this is why I suggested that the usage is > rhetorical. I don't think it is constraining implementations - it merely uses "pointer" with a different meaning (suggestion: "something that points to something") than the one you have in mind and which is used commonly in CS. >> and why? There is nothing weaselish about quoting the JLS. > > I'd be very interested to see the line in the spec that says > > 'It [Java] only has pointers for reference types' > > Show me that and watch me eat my hat. Can we skip the "show" part and directly go to "eat my hat"? ;-) >> I think most people in software engineering actually use the terms the >> way you have presented them here which is also reflected in the article >> about pointers on wikipedia. That does not preclude other usages in >> specific context so the heads up of Lew is actually in order to keep us >> alert and use terms consciously. > > Of course it is, how could I possibly imagine that it could ever be > otherwise. See? ;-) > Although ... actually, forget it, it really isn't that important, the > sun is shining and I have seeds to sow, the lawn to cut and frogs to > watch in the pond. I'll send our cat over. Here it's still uncomfortably cold (although getting better) and she prefers to stay in an demonstrate her bad temper... Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-04-06 18:13 +0100 |
| Subject | Re: arrays and variables |
| Message-ID | <1padnYcK9sRayv3MnZ2dnUVZ8lSdnZ2d@bt.com> |
| In reply to | #23349 |
On 06/04/13 16:50, Robert Klemme wrote: > On 06.04.2013 17:25, lipska the kat wrote: >> On 06/04/13 14:20, Robert Klemme wrote: >>> On 06.04.2013 10:11, lipska the kat wrote: >>>> On 05/04/13 21:33, Lew wrote: >>>>> lipska the kat wrote: >>>>>> Stefan Ram wrote: >>>>>>> Arved Sandstrom writes: >>>>>>>> Stefan Ram wrote: >>>>>>>>> Arved Sandstrom writes: >>>>>> >>>>>> [snip] >>>>>> >>>>>>> What is C? We have pointers in Java, see the JLS. >>>>>> >>>>>> Do we? I never knew that >>>>> >>>>> It's in the JLS, 4.3.1. >>>>> "An object is a class instance or an array. >>>>> >>>>> "The reference values (often just references) are pointers to these >>>>> objects, >>>>> and a special null reference, which refers to no object." >>>> >>>> This is a rhetorical usage of the word pointer and says nothing about >>>> the underlying mechanism used to implement references. >>> >>> Why "rhetorical"? >> >> The Java Language Specification is just that, a specification. >> Constraining an implementation to use *pointers is not within the >> purview of the specification, this is why I suggested that the usage is >> rhetorical. > > I don't think it is constraining implementations - it merely uses > "pointer" with a different meaning (suggestion: "something that points > to something") than the one you have in mind and which is used commonly > in CS. > >>> and why? There is nothing weaselish about quoting the JLS. >> >> I'd be very interested to see the line in the spec that says >> >> 'It [Java] only has pointers for reference types' >> >> Show me that and watch me eat my hat. > > Can we skip the "show" part and directly go to "eat my hat"? ;-) > >>> I think most people in software engineering actually use the terms the >>> way you have presented them here which is also reflected in the article >>> about pointers on wikipedia. That does not preclude other usages in >>> specific context so the heads up of Lew is actually in order to keep us >>> alert and use terms consciously. >> >> Of course it is, how could I possibly imagine that it could ever be >> otherwise. > > See? ;-) > >> Although ... actually, forget it, it really isn't that important, the >> sun is shining and I have seeds to sow, the lawn to cut and frogs to >> watch in the pond. > > I'll send our cat over. Here it's still uncomfortably cold (although > getting better) and she prefers to stay in an demonstrate her bad temper... Bloody cats, crapping in my veg beds, digging up my seedlings, hissing and howling and sitting by the pond pulling the pond weed out with their paws trying to get at the frogs. Grrrrrrrrrrrrrrr :-) lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Arved Sandstrom <asandstrom2@eastlink.ca> |
|---|---|
| Date | 2013-04-06 14:32 -0300 |
| Subject | Re: arrays and variables |
| Message-ID | <8%Y7t.491218$Q91.27753@newsfe26.iad> |
| In reply to | #23350 |
On 04/06/2013 02:13 PM, lipska the kat wrote: > On 06/04/13 16:50, Robert Klemme wrote: [ SNIP ] >> >> I'll send our cat over. Here it's still uncomfortably cold (although >> getting better) and she prefers to stay in an demonstrate her bad >> temper... > > Bloody cats, crapping in my veg beds, digging up my seedlings, hissing > and howling and sitting by the pond pulling the pond weed out with their > paws trying to get at the frogs. > > Grrrrrrrrrrrrrrr :-) > > lipska > Don't hold back. How do you really feel about cats? AHS
[toc] | [prev] | [next] | [standalone]
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Date | 2013-04-06 15:02 +0200 |
| Subject | Re: arrays and variables |
| Message-ID | <asaknoFh8s7U1@mid.individual.net> |
| In reply to | #23342 |
On 05.04.2013 22:33, Lew wrote: > lipska the kat wrote: >> a pointer in C >> >> int x >> int *iptr; >> iptr = &x; >> iptr++; //stupid but not illegal >> >> How would I do that in Java using pointers (note the *pointer arithmatic*). > > Java does not have pointer arithmetic. > > It only has pointers for reference types, so the nearest equivalents are: > > int x; > Integer iptr; > iptr = Integer.valueOf(x); > // no pointer arithmetic Albeit: iptr has different semantics than in the C list because it does not alias the original value. An assignment to x after this line will go unnoticed by anybody using iptr while in C/C++ it will be noticed. Well, that's they way it is... Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
[toc] | [prev] | [next] | [standalone]
| From | Arved Sandstrom <asandstrom2@eastlink.ca> |
|---|---|
| Date | 2013-04-05 22:12 -0300 |
| Subject | Re: arrays and variables |
| Message-ID | <4EK7t.336779$Hq1.219812@newsfe23.iad> |
| In reply to | #23337 |
On 04/05/2013 05:56 AM, Stefan Ram wrote: > Arved Sandstrom <asandstrom2@eastlink.ca> writes: >> On 04/05/2013 03:09 AM, Stefan Ram wrote: >>> Arved Sandstrom <asandstrom2@eastlink.ca> writes: >>>> Each one of those elements - char variables as per the JLS - >>>> points to an immutable thing >>> We do not use »point« for variables of primitve types like >>> »char«. A variable »has« a value. >> Who is "we"? > > All persons in this newsgroup except you. > > (I will feel refuted, should anyone /else/ answer now, that > he also would say that after the assignment a[ 5 ]= 'a', > the variable a[ 5 ] »pointed« to the value 'a'.) Nobody else may. Doesn't bother me none. Given that you yourself have made it clear that according to JLS a variable is a storage location, I'm happy to use the term "point" somewhat informally. >> And don't get all hung up on my use of the English word >> "point", I am not implying an equivalence with C pointers here. > > What is C? We have pointers in Java, see the JLS. Mindful of what Lew said below, can we assume that Java pointers are the same as C pointers? Well, no, they are not. It's again an example of an English word being used for similar but not identical concepts. >> You are entirely missing my argument. I know there's an English word > > >"mutable" > > , and I know what it means. My argument is that it would be >> seriously helpful if it were not used for > > >*changing the value* of a variable. > > I agree. The sentence > > »I am changing the value of a variable.« > > does surely not have the same meaning as > > »I am mutable.« > To be precise, I'd prefer never to say that a variable is mutable or immutable. I'd prefer to use those terms to describe what the variable points to. AHS
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-04-04 10:35 +0100 |
| Subject | Re: Usefulness of "final" (Was: Re: Inserting In a List) |
| Message-ID | <4_ydnVbj7JDV1MDMnZ2dnUVZ8h6dnZ2d@bt.com> |
| In reply to | #23283 |
On 04/04/13 09:37, Arved Sandstrom wrote: > On 04/04/2013 05:09 AM, lipska the kat wrote: >> On 03/04/13 20:01, Joerg Meier wrote: >>> On Wed, 03 Apr 2013 19:51:05 +0100, lipska the kat wrote: > [ SNIP ] > >> >>> What you are thinking of is immutability, something that is not >>> formalized in Java. In Java, having final mutable fields is perfectly >>> legitimate. >> >> Can you give an example? > > This is more a matter of incorrect English. An *object* is mutable or > immutable, not a field. For variables or fields I'd never use the terms > mutable/immutable; I'd prefer simply "final" or "not final" or something > similar. > > What Joerg meant is that if the final field is of a reference type then > it is perfectly possible that the object assigned to it is mutable. Something which I have never argued against. There are no two ways about it, a final variable is not modifiable once assigned to, the fact that the variable is a reference to a possibly modifiable instance of something or other is irrelevant to my original assertion. A variable that is final is no longer variable, it is not modifiable, on that I think we all agree. Another enjoyable discussion. lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2013-04-04 14:02 +0200 |
| Subject | Re: Usefulness of "final" (Was: Re: Inserting In a List) |
| Message-ID | <uxo9iz2kmqb8$.f9rtykdchdu9$.dlg@40tude.net> |
| In reply to | #23288 |
On Thu, 04 Apr 2013 10:35:02 +0100, lipska the kat wrote:
> On 04/04/13 09:37, Arved Sandstrom wrote:
>> On 04/04/2013 05:09 AM, lipska the kat wrote:
>>> On 03/04/13 20:01, Joerg Meier wrote:
>>>> On Wed, 03 Apr 2013 19:51:05 +0100, lipska the kat wrote:
>> [ SNIP ]
>>>> What you are thinking of is immutability, something that is not
>>>> formalized in Java. In Java, having final mutable fields is perfectly
>>>> legitimate.
>>> Can you give an example?
>> This is more a matter of incorrect English. An *object* is mutable or
>> immutable, not a field. For variables or fields I'd never use the terms
>> mutable/immutable; I'd prefer simply "final" or "not final" or something
>> similar.
>> What Joerg meant is that if the final field is of a reference type then
>> it is perfectly possible that the object assigned to it is mutable.
> Something which I have never argued against.
> There are no two ways about it, a final variable is not modifiable once
> assigned to, the fact that the variable is a reference to a possibly
> modifiable instance of something or other is irrelevant to my original
> assertion.
> A variable that is final is no longer variable, it is not modifiable, on
> that I think we all agree.
Correct. I disagreed with your statement (emphasis added by me):
On Wed, 03 Apr 2013 19:51:05 +0100, lipska the kat wrote:
> [...] When I see the
> modifier final it says something to me, it says, this *value* is not
> modifiable ('scuse the pun).
The variable/reference itself is not modifiable, but its VALUE certainly
is. And that, I feel, is the problem with using final to mean "this will be
the same throughout the code":
final Point p = new Point(0,0);
You can not be sure that the value of p will stay 0,0 throughout the code.
Liebe Gruesse,
Joerg
--
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-04-04 13:41 +0100 |
| Subject | Re: Usefulness of "final" (Was: Re: Inserting In a List) |
| Message-ID | <8PSdnU6kk5l36cDMnZ2dnUVZ7r6dnZ2d@bt.com> |
| In reply to | #23291 |
On 04/04/13 13:02, Joerg Meier wrote:
> On Thu, 04 Apr 2013 10:35:02 +0100, lipska the kat wrote:
>
>> On 04/04/13 09:37, Arved Sandstrom wrote:
>>> On 04/04/2013 05:09 AM, lipska the kat wrote:
>>>> On 03/04/13 20:01, Joerg Meier wrote:
>>>>> On Wed, 03 Apr 2013 19:51:05 +0100, lipska the kat wrote:
[snip]
>> A variable that is final is no longer variable, it is not modifiable, on
>> that I think we all agree.
>
> Correct. I disagreed with your statement (emphasis added by me):
>
> On Wed, 03 Apr 2013 19:51:05 +0100, lipska the kat wrote:
>> [...] When I see the
>> modifier final it says something to me, it says, this *value* is not
>> modifiable ('scuse the pun).
>
> The variable/reference itself is not modifiable, but its VALUE certainly
> is.
Nooooo, I just Can't agree with this I'm afraid :-)
The *value* of a reference variable is (an abstraction of) a memory
address. That value cannot be changed if the final modifier is used at
declaration time,
The *value* at the address that the reference variable refers to may or
may not be modifiable.
> And that, I feel, is the problem with using final to mean "this will be
> the same throughout the code":
>
> final Point p = new Point(0,0);
>
> You can not be sure that the value of p will stay 0,0 throughout the code.
But this is not what I would assume at all.
Looking at your example I see a variable p of type Point.
The variable p has the final modifier applied which means that p will
always point(:) to that instance of Point. p cannot be re-assigned,
therefore the value of p is not modifiable. That's all it means, I have
never assumed or suggested otherwise. what you do with the instance
referred to by p is another matter entirely.
I think it would be more correct to refer to the *value of Point p* as
opposed to the value of p, p is not modifiable, Point p is.
It's a question of terminology I suppose and the semantics of words like
value in the context of Java variables.
lipska
--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2013-04-04 13:53 +0200 |
| Subject | Re: Usefulness of "final" (Was: Re: Inserting In a List) |
| Message-ID | <1am5gx1sikt9s.1lpq5tinmsjr1$.dlg@40tude.net> |
| In reply to | #23282 |
On Thu, 04 Apr 2013 09:09:12 +0100, lipska the kat wrote:
> There's a lot that's been added to this thread since I retired to my bed
> last night and I haven't read it all so please excuse me if I'm
> repeating what others have said.
Same here.
> //OK, the instance is not immutable
> list.add("foo");
This is the case I was referring to: making the reference to list final
does not make the list object immutable.
> This is what I mean by not modifiable, the variables x and list are
> not modifiable after assignment however what list points to, sorry
> refers to is a mutable instance of ArrayList<String>, this is quite
> different.
>> "final" makes a variable or field impossible to reassign. It says
>> absolutely nothing at all about whether or not that variables is
>> modifiable.
> I'm not sure I understand
I must admit that I didn't consider primitives in my wording. I was talking
mostly about mutable objects - making a final reference to them does not
prevent modifying the object. I fear the attempt to include primitives in
definitions like this is futile - I don't even know whether I would
consider primitives immutable or not. int i = 1; i++; // Does the 1 get
modified to a 2, or overwritten by a 2 ?
>> What you are thinking of is immutability, something that is not
>> formalized in Java. In Java, having final mutable fields is perfectly
>> legitimate.
> Can you give an example?
Yes, but I don't need to: you already did, it's the one I quoted above.
your list was a mutable final field.
Liebe Gruesse,
Joerg
--
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Date | 2013-04-03 23:05 +0200 |
| Subject | Re: Usefulness of "final" (Was: Re: Inserting In a List) |
| Message-ID | <as3jtpF87eU1@mid.individual.net> |
| In reply to | #23222 |
On 03.04.2013 20:51, lipska the kat wrote:
> On 03/04/13 18:08, Robert Klemme wrote:
>> I am not sure what you mean by that. Can you elaborate? Where's the
>> storage class in the example above?
>
> final, although it's not is it, at least it's not Java terminology,
> apologies, I should have said 'modifier'. I'll restate.
Ah, OK, I see. Thanks!
> Well I'm not sure that using a modifier to help you write a
> conditional statement is 'good programming style'. When I see the
> modifier final it says something to me, it says, this value is not
> modifiable ('scuse the pun).
Sometimes you need nested conditions as shown and with a blank final you
can ensure that the variable is assigned exactly once on every possible
path. I find that useful.
> Is it improving the clarity of your code to
> use final for it's side effect, that is the side effect of causing the
> compiler to barf because a final variable may already have been
> initialized. I'm not sure about that.
That's not a side effect - it is _the_ effect of "final" modifier for
variables. "final" ensures a variable is assigned to at most once:
http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.12.4
There is no other effect - final is all about assignment. This is true
for local variables - it's different with field which get assigned
compile time constants.
I'd say, "final" is probably even more useful for fields because it
ensures that a field is initialized in every constructor path - you
cannot forget it.
http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.3.1.2
> For a single local variable I'd probably agree, in fact in general I
> would agree but that wasn't my initial point really, in the code that
> kicked off this sub thread there was more than one final variable, in
> fact there were several in close proximity, I was initially questioning
> the clarity of this for a new user. However then I opened my mouth and
> put my foot in it and said ...
:-)
>> Maybe I could better see (and agree) if you provide a specific example
>> of what you mean here.
>
> I think you probably know what I mean and any off the cuff example will
> be contrived to the point irrelevance, so, leave it with me and I'll see
> if I can come up with a simple self contained example.
Thank you!
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2013-04-02 22:09 +0200 |
| Message-ID | <1gi6rzoh3bk90.13qnp5sydac70.dlg@40tude.net> |
| In reply to | #23184 |
On Tue, 02 Apr 2013 15:08:53 +0100, lipska the kat wrote: > Just as a matter of interest what's with all the finals final further describes what is happening - namely, whereas "File name" says "I'm making a local variable named name of the type File", "final File name" says "I'm making a local variable named name of the type File, assigning it here, and then it will always stay that". In general, I prefer being more clear over being less clear, at the cost of being more verbose. > particularly > for (final File name : folder.listFiles()) > Despite initial appearances this is indeed legal as the > assignment is made multiple times but from the same statement. In this case, it signals that inside the loop, name is not reassigned. > > Given that the final keyword is, aside from a flag to the compiler for > possible optimization, largely documentary, what is the point of making > name final. > In fact what does peppering the code with finals do to make it easily > understandable to an inexperienced developer ? It doesn't at all. I have my IDE set to automatically make final what it can, because I'm often lazy and forget to do it myself, and didn't even think about it when copying the code back (as for why I put it in my IDE in the first place, I wanted to confirm that Sysout(myList) was indeed identical to Sysout(Arrays.toString(myList.toArray())). So, I honestly didn't even realize that my IDE put in the finals, because I'm so used to it by now. Didn't give it any more thought than I gave the fact that my IDE did proper code formatting on it. In retrospect, without an explanation, it's probably more confusing than helpful to a newbie, so it's good that you brought the issue up. Liebe Gruesse, Joerg -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-04-02 20:03 -0400 |
| Message-ID | <515b71c3$0$32114$14726298@news.sunsite.dk> |
| In reply to | #23184 |
On 4/2/2013 10:08 AM, lipska the kat wrote:
> On 02/04/13 13:35, Joerg Meier wrote:
>> On Tue, 2 Apr 2013 03:11:53 -0700 (PDT), subhabangalore@gmail.com wrote:
>>
>>> I am taking out the files in my desktop folder, as,
>>
>>> [...]
>>
>>> I am getting name of files individually but I want to see them as the
>>> whole bunch like,
>>
>>> myList=["string1","string2","string3",...."StringN"]
>>
>> You need to move the list assignment out of the loop, like so:
>>
>> final File folder = new File("G:\\Media\\TV Show");
>> final ArrayList<String> myList = new ArrayList<String>();
>> for (final File name : folder.listFiles()) {
>> final String s1 = name.toString();
>> System.out.println("####" + s1);
>> System.out.print(name);
>> myList.add(s1);
>> }
>
> Just as a matter of interest what's with all the finals
>
> particularly
>
> for (final File name : folder.listFiles())
>
> Despite initial appearances this is indeed legal as the
> assignment is made multiple times but from the same statement.
>
> Given that the final keyword is, aside from a flag to the compiler for
> possible optimization, largely documentary, what is the point of making
> name final.
>
> In fact what does peppering the code with finals do to make it easily
> understandable to an inexperienced developer ?
The performance optimization benefits of final is a myth
solid founded in how JVM's from the 1990's worked.
The generous usage of final is an attempt to make
Java a more functional language.
I don't like it. If I want to program in a functional style, then
I would pick a functional language.
Arne
[toc] | [prev] | [next] | [standalone]
| From | Wanja Gayk <brixomatic@yahoo.com> |
|---|---|
| Date | 2013-04-06 21:39 +0200 |
| Message-ID | <MPG.2bca982bc66d86d298974f@202.177.16.121> |
| In reply to | #23184 |
In article <ntKdnSTV5a3le8fMnZ2dnUVZ8kmdnZ2d@bt.com>, lipska the kat (lipska the kat) says... > Just as a matter of interest what's with all the finals > > particularly > > for (final File name : folder.listFiles()) > > Despite initial appearances this is indeed legal as the > assignment is made multiple times but from the same statement. > > Given that the final keyword is, aside from a flag to the compiler for > possible optimization, largely documentary, what is the point of making > name final. > > In fact what does peppering the code with finals do to make it easily > understandable to an inexperienced developer ? In my opinion it's been an unfortunate decision to have a "final" keyword instead of a "var" keyword with a "final" default. Now, I'm a fan of using the "final" keyword everywhere possible apart from method and class declarations and I'll give you my reasons behind it. a) It expresses more exactly what the code really does. I think that a certain precision of expression is of beauty. This is a rather stylistic view. b) As soon as you're used to having every possible assignment declared "final", each missing "final" will stand out like an alarm sign - you immedeately spot those assignments that change their value. It greatly helps me understand the code. So it is of practical value, once you're used to it. c) If I mistakingly (mistyping, code completion errs) assign a value to a "final" reference, the compiler will warn me immediately. Since I always declare "final" what is never intended to change, this stops me from making stupid mistakes. I find this is of a hugepractical value. d) I hardly have any problem with using a value in an anonymous class and if I have, It tells me that I'm probably doing something stupid. e) Adding parameters to methods is a code smell, each "final" keyword augments that by growing the signature even faster. I find it funny, that one of the biggest design mistakes in the language (no final default) is actually of some benefit here. Once you always use "final" where appropriate, and became used to it, the visual clutter starts to disappear. Kind regards, -Wanja- -- ..Alesi's problem was that the back of the car was jumping up and down dangerously - and I can assure you from having been teammate to Jean Alesi and knowing what kind of cars that he can pull up with, when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer] --- news://freenews.netfront.net/ - complaints: news@netfront.net ---
[toc] | [prev] | [next] | [standalone]
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Date | 2013-04-07 01:08 +0200 |
| Message-ID | <asbo88Fp489U1@mid.individual.net> |
| In reply to | #23353 |
On 06.04.2013 21:39, Wanja Gayk wrote: > e) Adding parameters to methods is a code smell, each "final" keyword > augments that by growing the signature even faster. I find it funny, > that one of the biggest design mistakes in the language (no final > default) is actually of some benefit here. > > Once you always use "final" where appropriate, and became used to it, > the visual clutter starts to disappear. Which goes a bit against item e. ;-) I do agree with all your other points. Put much better than I did it before. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-04-06 22:15 -0700 |
| Message-ID | <782eaeb3-186d-43ec-9ba2-9c6605a7a085@googlegroups.com> |
| In reply to | #23353 |
Wanja Gayk wrote: > In my opinion it's been an unfortunate decision to have a "final" > keyword instead of a "var" keyword with a "final" default. I respect that opinion but I hold it not, mostly because I came to Java after it was invented and didn't have any say in the matter. > Now, I'm a fan of using the "final" keyword everywhere possible apart > from method and class declarations and I'll give you my reasons behind > it. However, I do hold that this style is, formally, desirable. Except you should use it on method and class declarations, too. As Bloch says, you should design for heritability or prevent it. > a) It expresses more exactly what the code really does. I think that a > certain precision of expression is of beauty. This is a rather stylistic > view. Indeed, it is a style view, and everywhere I've worked has also had a style view. > b) As soon as you're used to having every possible assignment declared > "final", each missing "final" will stand out like an alarm sign - you > immedeately spot those assignments that change their value. It greatly > helps me understand the code. So it is of practical value, once you're > used to it. Defensive programming is a defensible practice. Detractors should understand that there is nothing of "helping the compiler" about this. These are all justifications of semantics, and therefore relevant. > c) If I mistakingly (mistyping, code completion errs) assign a value to > a "final" reference, the compiler will warn me immediately. Since I > always declare "final" what is never intended to change, this stops me > from making stupid mistakes. I find this is of a hugepractical value. It's part of the larger strategy of getting the compiler to do as much work for you as possible. My twisted mind says that Java's lack of runtime generics is an asset in this regard. It forces the programmer to work much harder to get the type semantics correct at compile time, and yes, oh, dear, to use an explicit run-time type token (RTTT) when runtime genericity is de rigueur. But then at least you have whatever type assertions possible handled by the compiler. Okay, yes, I would appreciate runtime generics, but it's still a good idea to push things to compile time. > d) I hardly have any problem with using a value in an anonymous class > and if I have, It tells me that I'm probably doing something stupid. I think I get what you're saying here, but I'm not sure. > e) Adding parameters to methods is a code smell, each "final" keyword > augments that by growing the signature even faster. I find it funny, > that one of the biggest design mistakes in the language (no final > default) is actually of some benefit here. It's a choice. I disagree that it's a mistake. At least you can put 'final' everywhere, even though it's annoying that you must. > Once you always use "final" where appropriate, and became used to it, > the visual clutter starts to disappear. I don't think the anti-'final'ists buy this one. I don't agree that adding parameters to methods per se is code smell, but it is not to be abused either. If you factor your model correctly you usually don't create a whole lot of overloads, and those not too abundant. Anyway. But you do add parameters when you need to, though pundits now suggest using builders instead. That makes the use of a mutable type (sorry, purists) explicit and temporary, which is usually right. And again there are exceptions to the rule. It's like a rubber band - the farther you get from rules of thumb like "keep parameters few and overloads fewer", the greater the tension. It doesn't mean never do it, it does mean understand that the tension is there for a reason, and you should minimize it. Truly everywhere I work people would stick my head in the teapot like the dormouse if I were to use 'final' like that. Like essay and paper publication, there is a house style in every house. And it isn't really all that necessary anyway. Another rule of thumb is to keep methods short. In a short space you hardly need 'final' to tell you not to change a local variable. You hardly have time to use it once, let alone fear reassignment. So I cheerfully follow the seat-of- the-pants crowd on this one. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-04-07 08:48 +0100 |
| Message-ID | <f7mdnbacALx-ufzMnZ2dnUVZ8hudnZ2d@bt.com> |
| In reply to | #23358 |
On 07/04/13 06:15, Lew wrote: > Wanja Gayk wrote: >> In my opinion it's been an unfortunate decision to have a "final" >> keyword instead of a "var" keyword with a "final" default. > > I respect that opinion but I hold it not, mostly because I came to Java after it > was invented and didn't have any say in the matter. > >> Now, I'm a fan of using the "final" keyword everywhere possible apart >> from method and class declarations and I'll give you my reasons behind >> it. > > However, I do hold that this style is, formally, desirable. > > Except you should use it on method and class declarations, too. As Bloch says, > you should design for heritability or prevent it. Huh! This is getting surreal, who is Bloch, it's you, at least I thought it was, you're messing with my head, stop it. lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-04-07 12:32 -0700 |
| Message-ID | <230151f0-533f-48d3-a4df-413f69444a33@googlegroups.com> |
| In reply to | #23359 |
lipska the kat wrote: > Lew wrote: >> As Bloch says, you should design for heritability or prevent it. > > Huh! This is getting surreal, who is Bloch, it's you, at least I thought > it was, you're messing with my head, stop it. Really? You are joking, no doubt, but just in case you aren't: http://www.oracle.com/technetwork/java/effectivejava-136174.html of course. Your head is of no concern to me. -- Lew
[toc] | [prev] | [next] | [standalone]
Page 7 of 9 — ← Prev page 1 2 3 4 5 6 [7] 8 9 Next page →
Back to top | Article view | comp.lang.java.programmer
csiph-web