how to call One constructor from another;
Answer Posted / ajay
Hi,
Using super you can invoke constructor which is in parent
class. to invoke constructor which is in the same class we
have to use this. for example:
public class Point {
int m_x;
int m_y;
//============ Constructor
public Point(int x, int y) {
m_x = x;
m_y = y;
}
//============ Parameterless default constructor
public Point() {
this(0, 0); // Calls other constructor.
}
. . .
}
| Is This Answer Correct ? | 21 Yes | 5 No |
Post New Answer View All Answers
Can It is possible to synchronize the constructor of a Java Class?
Why hashset is used in java?
What does string mean in java?
Can an abstract class be a final class?
What are format specifiers in java?
What is the size of arraylist in java?
What is singleton class in ruby?
How can you share data between two thread in Java?
Can I use % with real numbers?
What are the two types of java?
What is the use of string and stringbuffer?
Java.util.regex consists of which classes?
Is java util list serializable?
What is meant by polymorphism?
What is a treeset in java?