Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java constructor example

class Main {
  private String website;
  // constructor
  Main() {
    website = "'softhunt.net'";
  }

  public static void main(String[] args) {

    // constructor is invoked while
    // creating an object of the Main class
    Main obj = new Main();
    System.out.println("Welcome to " + obj.website);
  }
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #java #constructor
ADD COMMENT
Topic
Name
3+6 =