![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I write constructor names in Java?
Declaring a constructor is in Java is similar to methods. While naming the constructor of a class in Java you need to keep the following points in mind.
- The name of the constructor should be the same (same case) as the class name (along with the access specifier).
- A constructor should not have any return type.
- Constructor cannot be static, final, abstract and, synchronized.
Example
Following Java program is an example of a constructor.
public class Sample { Sample() { System.out.println("This is an example of a constructor"); } public static void main(String args[]) { new Sample(); } }
Output
This is an example of a constructor
Advertisements