Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java public no-arg constructor

class Tutorialweb {
  String website;

  // public constructor
  public Tutorialweb() {
    website = "Softhunt.net";
  }
}

class Main {
  public static void main(String[] args) {

    // object is created in another class
    Tutorialweb obj = new Tutorialweb();
    System.out.println("Tutorial website name = " + obj.website);
  }
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Java #public #constructor
ADD COMMENT
Topic
Name
5+1 =