about 9 years ago
Java Class Constructor
It is special kind of function, but doesn't have a return type.
It has the same name as class name.
Constructor is used to initialized the variable of class.
we can't call the constructor with the help of object. If we do so, then it will give compilation error.
Constructor is automatically call when we create the instance/object of class.
For Example:
Class abc { int a; abc(int b) //point 1 & 2 { b=a; //point 3 } void display() { System.out.println(a); //output= 9 } } class call { public static void main(String a[]) { abc obj= new abc(9); //point 5 obj.display(); obj.abc(9); // point 4 , compilation error } }
Note: If we don't write the constructor explicitly, then default empty (No-Argument) constructor will be generated by Compiler.
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)