Pointer Arithmetic
The difference here boils down to what's called pointer arithmetic. As I mentioned earlier, both Java and C# are based on C (and C++) syntax. When the creators of Java wanted a language to handle networks (among other things) seamlessly, they determined that C++ wasn't secure enough. Java was developed, in part, because C++ didn't have all the attributes deemed necessary for a programming language to operate effectively in a networked environment.
Despite its power, pointer arithmetic was judged too much of a security liability, so it was dropped from the Java language specification—along with other C++ features such as multiple inheritance and operator overloading—and .NET followed suit.
Don't confuse this conversation on pointer arithmetic with a totally different discussion on the difference between pointers and references (which causes a lot of confusion for students). Pointer arithmetic is the manipulation of pointers and their corresponding addresses. To clarify the distinctions, check out these definitions of pointers and references from "JavaDude" Scott Stanchfield:
- The value of a pointer is often the memory address of the data you're interested in. Some languages allow you to manipulate that address; others do not.
- A "reference" is an alias to another variable. Any manipulation done to the reference variable directly changes the original variable.
Coverage of the difference between pointers and references is beyond this discussion. This article focuses on pointer arithmetic—which C++ allows, and Java and .NET don't.