Panhu learn Java and the next day

Graphics class demo Deliverable
Graph Properties Attribute: None  
Graphics method Methods: main method calls class image

Each class has a constructor . If not explicitly defined for the class constructor, Java compiler will provide a default constructor for the class method.

Creating an object, at least, to be called a constructor. The name of the class constructor must be the same name, a class can have multiple constructors.

The following is an example of the constructor:

public class Puppy{
    public Puppy(){
    }
 
    public Puppy(String name){
        // This constructor is only one argument: name
    }
}

  

Guess you like

Origin www.cnblogs.com/dede-6/p/11648859.html