

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Constructor Overloading In Java programming
Similar to method overloading, constructor loading is the creation and usage of constructors with diffrent type of arguments. We can use this operator to refer to constructors.See the example below.
Example
class A { public int a; public A() { this(-1); } public A(int a) { this.a = a; } public String toString() { return "[ a= " + this.a + "]"; } } public class Tester { public static void main(String args[]) { A a = new A(10); System.out.println(a); A a1 = new A(); System.out.println(a1); } }
Output
[ a= 10] [ a= -1]
- Related Questions & Answers
- Constructor overloading in Java
- Overloading in java programming
- Constructor overloading in enumerations in Java.
- What is constructor overloading in Java?
- Constructor Overloading in C#
- Constructor Overloading in C++
- Constructor Chaining In Java programming
- Super constructor in Dart Programming
- Method overloading in Java
- Overloading Varargs Methods in Java
- Using Method Overloading in Java
- What is Overloading in Java?
- Default constructor in Java
- Enum constructor in Java
- Java default constructor
Advertisements