[問題] 關於陣列從0或1開始算起的好處
http://www.iis.sinica.edu.tw/~scm/ncs/2009/07/go-to-considered-harmful/
上面這個連結雖然是討論GOTO
不過Dijkstra大師在裡面說
『我以為到了現在,一個專業程式員該有高一點的自我要求了,陣列應該從0算起,
我以為到了現在,一個專業程式員該知道自然數從 0 開始的好處了』
但是我在看Core Java的時候作者又說了
『Java counts the code units in strings in a peculiar fashion:
the first code unit in a string has position 0.
This convention originated in C,
where there was a technical reason for counting positions starting at 0.
That reason has long gone away and only the nuisance remains.
However, so many programmers are used to this convention that
the Java designers decided to keep it.』
如果可以拋開歷史因素之類相容問題的話
那麼陣列索引到底是從0開始計算好,還是從1開始計算好呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.50.39.188
→
08/19 22:09, , 1F
08/19 22:09, 1F
→
08/19 22:10, , 2F
08/19 22:10, 2F
→
08/19 22:11, , 3F
08/19 22:11, 3F
→
08/19 22:11, , 4F
08/19 22:11, 4F
→
08/19 23:00, , 5F
08/19 23:00, 5F
→
08/20 00:10, , 6F
08/20 00:10, 6F
→
08/20 00:10, , 7F
08/20 00:10, 7F
→
08/20 00:13, , 8F
08/20 00:13, 8F
→
08/20 00:14, , 9F
08/20 00:14, 9F
→
08/20 00:14, , 10F
08/20 00:14, 10F
→
08/20 00:15, , 11F
08/20 00:15, 11F
→
08/20 00:16, , 12F
08/20 00:16, 12F
→
08/20 00:17, , 13F
08/20 00:17, 13F
→
08/20 00:17, , 14F
08/20 00:17, 14F
→
08/20 00:53, , 15F
08/20 00:53, 15F
→
08/20 00:54, , 16F
08/20 00:54, 16F
推
08/20 08:01, , 17F
08/20 08:01, 17F
→
08/20 11:42, , 18F
08/20 11:42, 18F
→
08/20 12:27, , 19F
08/20 12:27, 19F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 4 篇):