r/javahelp • u/Nix-X • Jul 22 '20
"Pointer" in java?
Was learning Recursion from GeeksforGeeks, when I came across this code snippet -
static void abc(char *s)
{
if(s[0] == '\0')
return;
abc(s + 1);
abc(s + 1);
System.out.print(s[0]);
} In Java, we have “references”, and not an actual “Pointer” type, by which we can go in to a memory address in the JVM directly. So, what is a char pointer doing in Java? Unless my whole life has been a lie?
Problem link - https://www.geeksforgeeks.org/practice-questions-for-recursion-set-6/.
0
Upvotes
6
u/mikeydoodah Jul 22 '20
Well, that's just not Java. Perhaps the website made a mistake when copying it? It looks like they just took the C code directly above it and changed the printf function to System.out.print.