- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
- Related Articles
- How do I write class names in Java?
- How do I write method names in Java?
- How do I write variable names in Java?
- How do I write interface names in Java?
- How do I write package names in Java?
- How do I write constants names in Java?
- How do I search for names starting with A in MySQL?
- Where and how can I create a private constructor in Java?
- How do we use an enum type with a constructor in Java?
- What do you mean by default constructor in Java?
- How do I create dynamic variable names inside a JavaScript loop?
- How do I compare strings in Java?
- Do static variables get initialized in a default constructor in java?
- How do I read (or write) binary data in Python?
- Why do we need a copy constructor and when should we use a copy constructor in Java?

Advertisements