Originally Posted by
ChazZeromus
4) When exactly when you would use the new keyword? I know that in C++ new is allocates memory so that a pointer can point to the new memory, but I notice that java does not have any pointer facilitation.
First, your topic/thread title is meaningless. You really should pick a meaningful title, as it will encourage folks to answer it.
One critical difference between Java and C (and assembler languages) that that you never use pointers. You can not do pointer arithmetic. There are no expresions that yield a pointer that you can do anything with.
The line:
MyObject myObj = new MyObject():
creates an instance of a MyObject() object, and the variable "myObj" is a reference to it. The reference works much like a C++ reference, and the syntax here is exactly what it is in C++. But it is illegal and illogical to do something like:
in Java, whereas it is fine in C++.