














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















Type Default Value
boolean False
byte (byte) 0
short (short)
int 0
long 0L
char \u 000
float 0.0f
double 0.0d
object information null
// Create an empty cup CoffeeCup cup1 = new CoffeeCup();
// Create a cup with 355 ml of coffee in it CoffeeCup cup2 = new CoffeeCup(355); } // Above requires constructor shown later }
Instance initialization
An instance initializer , also called an instance initialization block is shown here with the CoffeeCup class innerCoffee variable initialized by an instance initializer:
This manner of initializing innerCoffee yields the same result as the previous two examples: innerCoffee is initialized to 355.
// In source packet in file init/ex14/Liquid.java class Liquid { // Has two fields: private int mlVolume; private float temperature; // in Celsius // Has several methods, not shown... }
// In source packet in file init/ex14/Coffee.java class Coffee extends Liquid { // Has two fields: private boolean swirling; private boolean clockwise; // Has several methods, not shown... }