ITEC 1620 Lecture 14: 1620_lecture_14_slides
Document Summary
Constructors are a special method that return a new instance of a class. No return type must be instance of f t b i t t. P i bli l i bli public int x; public int y; public point (int x, int y) // parameters get assigned to instance variables d t t t t i i. Point corner = new point (3, 5); corner. Java does not know how to initialize your datatype. The constructor allocates space in memory for all the fields of the class memory for all the fields of the class. A constructor is a special method that has th the same name as the class th l. You must use the constructor before using your objects. Point pointa; pointa x = 0; pointa. x = 0; What does the declaration do? pointa p. Point pointa; p pointa = new point(); pointa = new point(); Non-primitive (object) fields initialized to p j.