how to call a parameterized constructor in java -
i new java ,i want call default parameterized constructor code not working java code
public class sample{ public static void main(string args[]){ 1 o=new one(25); } } class one{ public void one(string a){ system.out.println(a); } }
there mistake in code. remove void
constructor. more specific replace class with
class one{ public void one(string a){ system.out.println(a); } }
if adding return type, java consider method, instead constructor, though class name , method name (class name) similar.
also please not trying call constructor new one(25)
, incorrect. should pass argument string new one("25")
Comments
Post a Comment