Reputation: 25
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
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