user2980525
user2980525

Reputation: 25

Is it a method or a constructor?

i am a little comfused as to if the ex below is a constructor or a method. i know that constructor has the same name as a class but it does not return anything.

public class Point3D {

    public Point3D transform(Matrix m){

Upvotes: 0

Views: 67

Answers (1)

Habib
Habib

Reputation: 223267

It is a method which returns instance of the same class Point3D. It appears that the method after accepting a parameter is returning an instance of the same class after transforming it.

See: Providing Constructors for Your Classes

Constructor declarations look like method declarations—except that they use the name of the class and have no return type.

Upvotes: 6

Related Questions