CS 24L Object-Oriented Programming

[Home]

Some Important Java Facts

a. Case Sensitivity

Like its C++ counterpart, Java is case sensitive. For example, astring and aString are considered to be two distinct identifiers. For those with C++ experienced this should not cause any problems, however, some tips that can ease the situation are provided below.

b. Naming Conventions

The Java SDK class libraries generally follow the naming convention given below. By following a particular naming convention, the readability of the code is improved

c. Garbage Collection

To create an instance of a class, the new operator is used. However, there is no need for a delete operator since Java automatically removes objects that are not being referenced. This is known as Garbage Collection. This has the following advantages and disadvantages.

Advantages

Disadvantages

d. No Pointers

Java has no pointers but instead uses references. A reference provides access only to the functionality of the object. The programmer does not have direct access to memory removing the dangers of pointer manipulation. For example: Interestingly, the lack of pointers can be a hindrance in specific cases. For example, imagine trying to create a memory manager for an operating system without pointers.

e. No Global Variables

In Java, the global name space is the class hierarchy and so, one cannot create a variable outside of a class. This removes the possibility of side effects occurring on a system-wide basis due to some change in the state of a global variable. For example, it is extremely difficult (if not impossible) to ensure that a global variable is changed in a consistent and controlled manner. Java does allow a modified form of the global variable called static variables.


Copyright © 1999-2003, Colin Depradine. All rights reserved.