CCA Guide
Object-Oriented Programming

Object-Oriented Programming

Curated by Last modified: 1 min read

View Markdown

Classes

A class defines a type of object: a set of information (fields) and behaviors (methods).

Instantiation

Instantiation creates an object from a class, usually by calling a constructor with new.

Overloading

Overloaded methods have the same name and different parameter lists (number or types of parameters).

Correction to the original notes

Renaming parameters alone does not create a different method signature. The original parenthetical claim that parameters can simply be named differently was misleading.

public int doubleValue(int value) {
    return value * 2;
}

public double doubleValue(double value) {
    return value * 2;
}

Source: Java Language Specification §8.4.9.

Related: Introduction to Java · Methods

Linked to this page