This content has been marked as final. Show 8 replies
thanks .. but without pointers how can we pass arraypsst, don't tell anyone, but Java has pointers; they call them 'references'
(two dimensional) of strings... as we did in C..
though. Java doesn't have pointer arithmetic, but it definitely has pointers.
In fact, for any non-primitive, all that is passed is a copy of the pointer
value (it's all pass by value, just like C).
thanks jos, i am sorry i had misunderstood the concept... but thanksNo need to apologise; calling a pointer a 'reference' has caused more
again for the explanation.
confusion than just this, i.e. some folks new to Java assume that Java
supports call by reference (which it doesn't) and by taking away the
explicit '&', '*', '.' and '->' operators most (if not all) C programmers feel
dismemberd by Java.
All object variables (local,member or static) are just pointers to the real
object. Primitives (int, doubles etc) are stored as is, just as in C. Arrays
are objects too, so an array variable is also just a pointer to the real thing.
This scenario makes it so easy to allocate an object: allocate four bytes
per object member variable plush min(4, sizeof(x)) for every primitive
type member variable x. (and then add some for the implicit 'this' pointer).
Only the 'new' operator can do this, the user (programmer) can't.