Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #14591
| Newsgroups | alt.comp.lang.borland-delphi, comp.lang.c, comp.lang.java.programmer |
|---|---|
| From | Heikki Kallasjoki <fis+usenet@zem.fi> |
| Subject | Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) |
| References | <b3f1b$4fb4f87c$5419acc3$14079@cache60.multikabel.net> <29308868.1994.1337265697084.JavaMail.geo-discussion-forums@pbcuc6> <e69c4$4fb51b41$5419acc3$11300@cache100.multikabel.net> <slrnjra97k.d62.fis@iris.zem.fi> <84131$4fb54067$5419acc3$20839@cache90.multikabel.net> |
| Organization | nonexistent |
| Followup-To | comp.lang.java.programmer |
| Message-ID | <slrnjrajds.f35.fis@iris.zem.fi> (permalink) |
| Date | 2012-05-17 19:13 +0000 |
Cross-posted to 3 groups.
Followups directed to: comp.lang.java.programmer
On 2012-05-17, Skybuck Flying <Windows7IsOK@DreamPC2006.com> wrote:
>>> private static void rangeCheck(int arrayLen, int fromIndex, int toIndex)
>>> {
>>> if (fromIndex > toIndex)
>>> throw new IllegalArgumentException("fromIndex(" + fromIndex +
>>> ") > toIndex(" + toIndex+")");
>>> if (fromIndex < 0)
>>> throw new ArrayIndexOutOfBoundsException(fromIndex);
>>> if (toIndex > arrayLen)
>>> throw new ArrayIndexOutOfBoundsException(toIndex);
>>> }
>
> It seems likely this code is called right before the array is accessed to
> try and prevent an access violation, instead it tries to throw a somewhat
> nicer exception message to indicate a problem with array access.
No. It seems likely rangeCheck(10, 4, 7) is testing whether indices 4,
5 and 6 (that is the *range* from 4, inclusive, to 7, exclusive) are
within the bounds of an array of length 10, which it does just fine.
> It's simply not valid. Out of bounds has a very clear meaning in programming
> practice. It's either within bounds or it's not. The bounds of a java array
Yes, but it is not designed for testing whether fromIndex and toIndex
are within those bounds. It is used to test whether fromIndex,
fromIndex+1, ..., toIndex-1 are, which it does. In particular, the
element with index "toIndex" is not part of the range it's testing, so
it does not need to be inside the array bounds.
In other words, the range fromIndex=5, toIndex=10 denotes the elements
5, 6, 7, 8 and 9. It does not include element 10. rangeCheck(10, 5, 10)
is not supposed to throw an exception, nor does it do so.
(Would it be possible to also stop crossposting to all the unrelated
groups?)
--
Heikki Kallasjoki
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 15:09 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-17 09:23 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 17:26 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-17 16:19 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 19:57 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-05-17 18:33 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 23:25 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <lewbloch@gmail.com> - 2012-05-17 14:52 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-17 14:58 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-17 17:59 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-17 22:13 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-18 01:18 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-17 21:32 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Noob <root@127.0.0.1> - 2012-05-18 17:08 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 20:53 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 21:19 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-19 18:47 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-20 17:55 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 20:18 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 20:21 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 20:52 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:27 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-19 14:48 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-19 15:20 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-19 15:35 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:25 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) bugbear <bugbear@trim_papermule.co.uk_trim> - 2012-05-21 17:12 +0100
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-18 07:22 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-19 14:50 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:21 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:23 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-18 01:09 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:14 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:36 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-20 17:53 +0200
Re: names for parameters of ranges Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:30 -0400
Re: names for parameters of ranges Gene Wirchenko <genew@ocis.net> - 2012-05-20 20:48 -0700
Re: names for parameters of ranges (was: ...) Willem <willem@toad.stack.nl> - 2012-05-23 09:43 +0000
Re: names for parameters of ranges Willem <willem@toad.stack.nl> - 2012-05-23 11:07 +0000
Re: names for parameters of ranges Willem <willem@toad.stack.nl> - 2012-05-23 15:42 +0000
Re: names for parameters of ranges Willem <willem@toad.stack.nl> - 2012-05-23 11:11 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-17 19:13 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-05-17 19:19 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Jim Janney <jjanney@shell.xmission.com> - 2012-05-17 18:35 -0600
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 23:16 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:32 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:40 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-21 10:05 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 14:41 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:12 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Keith Thompson <kst-u@mib.org> - 2012-05-20 16:38 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-20 18:52 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Keith Thompson <kst-u@mib.org> - 2012-05-20 19:21 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) gazelle@shell.xmission.com (Kenny McCormack) - 2012-05-21 08:24 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Bill Leary" <Bill_Leary@msn.com> - 2012-05-23 14:34 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-05-20 21:46 -0600
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <noone@lewscanon.com> - 2012-05-21 00:04 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) gazelle@shell.xmission.com (Kenny McCormack) - 2012-05-21 08:25 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:46 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) jacob navia <jacob@spamsink.net> - 2012-05-17 18:54 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Mark Storkamp <mstorkamp@yahoo.com> - 2012-05-17 12:06 -0500
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) markspace <-@.> - 2012-05-17 10:11 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <lewbloch@gmail.com> - 2012-05-17 14:43 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) markspace <-@.> - 2012-05-17 16:13 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) markspace <-@.> - 2012-05-17 16:42 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Jan Burse <janburse@fastmail.fm> - 2012-05-18 02:27 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 15:06 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Marius" <sorry@nospamfor.me> - 2012-05-17 17:32 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-17 23:45 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Marius" <sorry@nospamfor.me> - 2012-05-17 22:16 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-18 00:47 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-24 14:11 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-24 14:17 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Roedy Green <see_website@mindprod.com.invalid> - 2012-05-18 02:57 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-05-18 05:26 -0500
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-18 08:08 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 14:46 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) rossum <rossum48@coldmail.com> - 2012-05-18 12:25 +0100
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Gene Wirchenko <genew@ocis.net> - 2012-05-18 10:46 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-19 21:01 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:33 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Patricia Shanahan <pats@acm.org> - 2012-05-20 16:30 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Gene Wirchenko <genew@ocis.net> - 2012-05-20 20:36 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Kaz Kylheku <kaz@kylheku.com> - 2012-05-21 04:28 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:55 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 09:49 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-21 10:08 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 10:45 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 11:13 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 11:19 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <lewbloch@gmail.com> - 2012-05-21 11:40 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 18:10 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-21 10:00 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-21 10:10 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) falk@rahul.net (Edward A. Falk) - 2012-05-23 05:40 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Jim Janney <jjanney@shell.xmission.com> - 2012-05-23 08:46 -0600
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) "Skybuck Flying" <Windows7IsOK@DreamPC2006.com> - 2012-05-24 14:03 +0200
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Lew <lewbloch@gmail.com> - 2012-05-24 09:56 -0700
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) falk@rahul.net (Edward A. Falk) - 2012-05-26 00:52 +0000
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@charter.net> - 2012-05-25 21:16 -0400
Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2012-05-24 09:42 -0700
csiph-web