A collection of programming & webdesign
Classes

A class should always have a constructor. The constructor initiates the data members.

The keyword this references to current class data members.

Structure of a class:

  1. includes
  2. parameters
  3. constructor
  4. methods

Hint: Always pass values in the main method (via constructor).

Class default modifier = internal (= accessible from other classes).

Instantiating an object:

Dog dog = new Dog(); 

  • dog = reference variable, it references to the heap where the object is created
  • new Dog() = new object

Dog tanny;

  • tanny = only reference, NOT the object

No object is created here in the second example.