previous | start | next

Creating Class Types

To create a user defined class type, the following steps are usually needed:

  1. Choose an appropriate name for your class type
  2. Begin with the syntax for a class:
    public class the_class_name_you_chose        
    {
    
    
    
    }           
             
    
  3. Decide what instance and/or static methods your class type will have.
  4. Decide what variables you will need in the class for each instance to "remember" and use between calls to its methods.
  5. Write one (or more) constructors for your class.

    A constructor executes when an instance of your class is created using the new operator.

    A constructor's purpose is to properly initialize the member variables before any of the methods are called.

  6. Write the methods.
  7. Write a separate class with a main method to test your new class type.


previous | start | next