Home  >  Forum  >  Core Java
Post New Query

constructor with same argument is possible in java?



Asked on June 04, 2015
constructor with same agrument is possible in java? 


Replied on June 04, 2015
no, not possible in same order but possible in different order.


Not Possible way--

public class MyClass{
public MyClass(int size, string name){}
public MyClass(int size, string name){}
}


Possible way --

public class MyClass{
public MyClass(int size, string name){}
public MyClass(string name, int size){}
}



Replied on June 04, 2015
A constructor must have the same name as the class and must not have a return type.

Write Answer







©2019 concretepage.com | Privacy Policy | Contact Us