Explain how function name and constructor can be same?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Explain how function name and constructor can be same??

public class Executor { Executor(){} void Executor() { System.out.println("Welcome Executor"); } public static void main (String[] args) { Executor e = new Executor(); e.Executor(); } }

6th Jun 2019, 11:02 AM
Heisenberg
Heisenberg - avatar
1 Answer
+ 2
a cunstructor is called like this: Executor e = new Executor(//constructor stuff) you call them differently so that why you can name them the same
6th Jun 2019, 11:06 AM
Cat Sauce
Cat Sauce - avatar