Pointers in Java

前端 未结 9 2066
梦毁少年i
梦毁少年i 2020-12-05 16:28

C++ supports pointers whereas Java does not. But when many programmers questioned how you can work without pointers, the promoters began saying \"Restricted pointers.” So we

9条回答
  •  没有蜡笔的小新
    2020-12-05 16:51

    When people say that Java doesn't support pointers, they are practicing newspeak. What Java calls references correspond exactly to what has always been known as pointers in the past.

    What Java doesn't support is pointer arithmetic. Which is something else entirely; as far as I know, C and its descendents are the only typed languages which support pointer arithmetic. Pascal and Modula-2, for example, have "pointers", described as pointers in their specifications, but these pointers have a semantic far closer to that of Java references; they don't allow pointer arithmetic.

提交回复
热议问题