Pointers


One of the major differences between Java and C++ is that Java does not support publicly accessible pointers. A pointer, as any C++ programmer knows , is a powerful tool that lets you directly access locations in memory. Pointers are also dangerous for the same reason, because they let you directly access locations in memory. More programming bugs are caused by misuse of pointers than any other reason.

Beyond increasing the likelihood of introducing bugs into your programs, pointers also pose a security risk in that a pointer can be used to access memory locations outside of those used by the program. A malicious programmer can use pointers to corrupt memory, damage system files, or do other heinous things.

The way the Java language is constructed makes pointers of marginal value anyway. Arrays are objects. You can access array elements using an index. Strings are likewise objects, so there is no reason to define a pointer to a string. There aren't any structures, so there is no need for pointers there. You don't need to use pointers as method arguments, because when a method argument is an object Java will automatically pass to the method a reference to the object.



Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net