Answer by Luke Melaia for Define constructor in Java
Of corse you can write a constructor for Main. Any class, enum and abstract class can have a constructor. Simple usagepublic Main(){ //Constructor code here...}Then to call main just use:Main main =...
View ArticleAnswer by Ankur Singhal for Define constructor in Java
I would like to know how can I define constructor in Java. I started writing piece of code but I get errors.Error is because constructor is defined inside main() method. Need to move outside. You can...
View ArticleAnswer by Stanislav for Define constructor in Java
Your constuctor must be like any other method declared (but it has to be called same, as the class name, and do not provide any return):public class ConstructorExample { //this is your class fieald...
View ArticleAnswer by Parker_Halo for Define constructor in Java
You cannot define a Constructor inside a method. You have to declare it like any other method in the class body.package xyz;public class ConstructorExample { public ConstructorExample(int x,int y){//...
View ArticleDefine constructor in Java
I would like to know how can I define constructor in Java.I started writing piece of code but I get errors.package xyz;public class ConstructorExample { public static void main(String[] args) { public...
View Article