Please enable JavaScript.
Coggle requires JavaScript to display documents.
Creating Constructors (Example (public Bunny(){} (no return type), public…
Creating Constructors
-
Overloading Constructors
-
Examples
public Hamster(int weight){
Sysout("in constructor");
this(weight, "brown")://Does not compile
}
-
public Hamster(int weight, String color){
this.color = color;
this.weight = weight;
}
-
-
-
-
Final fields
Examples
private static int volume;
private static final String name = "The Mouse House";
public MouseHouse(int length, int width, int height){
volume = length width height;
}
-
Order of Initialization
Memorize Rules
1 - If there is a superclass, initialize it first;
-
-
-
-