void methods




A void method is a method that performs some function but does not return a value.

Examples:


// this code segment assumes that slope is an instance variable
// and is of type double

public void calculateSlope(int x1, int y1, int x2, int y2)
{
    if (x1 != x2)
    {
        slope = (double)(y2-y1)/(x2-x1);
    }
}