Java supports pointers just fine, but they're called object references and always point to some subclass of Object. A point to an int is actually a reference to an Integer object that wraps a primitive int.
What Java doesn't allow is pointer arithmetic. You cannot blindly poke around in memory by altering references. The main reasons for this are safety and security. Pointer arithmetic is usually the source of many hard-to-find bugs, and being able to read/write anywhere makes security (sandboxing) difficult.
Actuallt, a function pointer would be a java.lang.reflect.Method object -- a little bit more typesafe than function pointers (since it contains information about the number of arguments, the parameter types, etc...), but that is all run-time checking -- the compiler won't catch it.
In short, Java does support everything you can do with pointers except add to them. And if your adding pointers together, then you really should think about diffrent ways to acheive the same end. Wht say "int i = myPointer+5;" when you can say "int cardValue = aCard.getCardValue();"
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Originally posted by Jason Fox: That brings up a question. Does the java compiler use pointer arithmetic behind the scenes, for things like walking through arrays?
Not the compiler (byte code doesn't contain any pointer arithmetic, as far as I know?), but the JVM surely does. How else could it work?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
subject: why java doesnot support pointer concept?