Where do objects come from? Objects are instances of classes We instantiate classes: –e.g.new chapter1.Terrarium() –There are three parts to this expression: new chapter1.Terrarium ()
new chapter1.Terrarium() ‘new’ is a “reserved word” in Java. This means that the word ‘new’ has a special meaning in the Java language. ‘new’ is the name of an operator whose job it is to create an instance of a given class chapter1.Terrarium is the name of the class we are instantiating. It is a compound name, consisting of a package name (chapter1) and the name of the class’ constructor (Terrarium), separated by a dot ‘.’ A constructor initializes the state of a newly created object. The parentheses delimit the argument list of the constructor call. In this case there are no arguments being passed along to the constructor, so the argument list is empty.
Packages A package is an organizational mechanism One analogy: –package::class –area code::phone number A class’ fully qualified name consists of its package name and its (unqualified) class name: –chapter1.Terrarium is a fully qualified class name –Terrarium is an unqualified class name
On to Eclipse package lecture; class EcoSystem { public EcoSystem() { }