10 Reasons We Need Java 3.0
Subject:   Idea about constructor naming
Date:   2002-08-06 07:20:04
From:   mcmilwj
I've always wondered why constructors need to be named with the name of the class. Why not use a generic identifier: this() or ctor()...scratch that (no abbreviations right): constructor() for the default and overloads too. Whenever I've wanted to change the name of a class, it has seemed to me that having to rename all your constructors was kind of silly. Why are we forced to state the name of the class in multiple locations? Just a thought.
Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Idea about constructor naming
    2005-02-22 05:24:45  bluetooth [View]

    When learning Java we're told:
    "The constructor is a method named after the class with no return type"

    I've always thought it makes more sense to say:
    "The constructor is a method with no name that returns an object of the type that it constructs"

    It makes the syntax make more sense, to me. Also, your IDE should be able to refactor the constructor names when you re-name a class.