c - Pointer to pointer equivalent in java -


this question has answer here:

for last day learning java while have knowledge in c. trying convert code written in c java code. there found pointer pointer (pptr)variable declaration -

   int  n;    int  *ptr;    int  **pptr;     n = 13;     ptr = &n;    pptr = &ptr;   

as far know, in java there no pointer type variable. question there way represent pptr or equivalent of pptr in java?

the short answer yes. first, lesson in java...

in java, whenever use objects, pointers involved. if have object, variable "holds" object pointer object. if working objects, using pointers.

now primitive data types (e.g., integers, chars, or floating point numbers), java not use pointers, though. if want pointers primitive data types, need use wrapper class, such integer, promotes value object.

note, however, default wrapper classes immutable.

if want double-pointers (a pointer pointer) or triple pointers, need create custom wrapper classes, objectwrapper class, allows set arbitrary number of objects each pointing (or "holding") next.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -