+ 4
what is the difference between the pointer in C and the reference type injava
1 Antwort
+ 5
A full answer can be found indepth on StackExchange by Joachim Sauer, so here is my short summary.
Pointers in C can perform pointer arithmetic, whereas java references can not. As you can't manipulate the underlying value of a reference in Java.
Java references are strongly typed. Whereas a pointer in C can be cast from int* to char*. In Java you can cast an Object ref to a String, only if that Object is actually a String
This makes Pointers in C more flexible/powerful than Java References. However, this also means that Pointers in C are more dangerous.