Constructor In Java Example
Chapter:
Java Basics
Last Updated:
02-05-2016 19:14:28 UTC
Program:
/* ............... START ............... */
public class JavaConstructorExample {
public static void main(String[] args) {
Welcome welcome = new Welcome("Welcome To JavaScan");
System.out.println("Welcome info: " + welcome.info);
}
}
class Welcome {
String info;
Welcome(String info) {
this.info = info;
}
}
/* ............... END ............... */
Output
Welcome info: Welcome To JavaScan
Tags
Constructor, Java , Java Basics