I'm a c#/java programmer and haven't really played around with pointers much. I'm just wondering if it's something that's useful enough to learn.
Could someone explain why and what exactly the pointers will help c#/java programmers with?
I'm a c#/java programmer and haven't really played around with pointers much. I'm just wondering if it's something that's useful enough to learn.
Could someone explain why and what exactly the pointers will help c#/java programmers with?
You are already using pointers all the time. Every non-primitive variable in Java (and presumably also C#, though I am less familiar with it) is a pointer to an object.
Perhaps you want to ask about pointer arithmetic?
Because pointers let you actually access the RAM manually (impossible in Java or in "safe" C#), and they let you have control over how things are allocated.
Variables that "hold" objects in C# and Java are really holding pointers (also loosely called references) to the objects in memory, hence why classes are called "reference types". By contrast, structs are "value types", so struct variables actually holds the data themselves. Pointers let you allocate and access memory dynamically, and without any safety checks on the compiler's part -- they give you some potential performance boosts, but they burden you with checking your code and ensuring its correctness.
The reason for this is a bit subtle: You need pointers since, in order to use memory, you need to know the size of the memory you need at compile time. But of course you can't ever be sure that a user won't try to load a 100-MB file into your program that was only designed to handle 20 MB, and, on the other hand, you can't reserve that much since the beginning (think about what would happen if everyone reserved all the resources). So you ask the operating system to allocate a block of memory for you and give you the address of its first byte, and that's why pointers are needed. (There's other uses for pointers, like memory-mapped files and devices, but that'd make the post longer.)
Performance-critical applications, as well as applications that are full of bugs, both often use pointers heavily. :)
I think that by understanding pointers you'll better understand what really happens within your computer, what's going on in there and how your programs can actually work.
If you don't care about it, and just want your java programs to work you could skip them; otherwise I think they'll help you with anything concerning programming.