Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to declare a constructor in Java?
While declaring the constructors you should keep the following points in mind.
- A constructor does not have a return type.
- The name of the constructor is same as the name of the class.
- A class can have more than one constructor.
Example
public class Sample {
int num;
public Sample() {
num = 30;
}
public Sample(int value) {
num = value;
}
}
Advertisements
