Instance Method – CSC142 Computer Science II Zhen Jiang CS Dept. West Chester University 4/11/2019
Table of Contents Introduction Declaration and call Access and scope 4/11/2019
Introduction Why? Why loop Why array Why method Why object (the host of instance method)? 4/11/2019
ArrayOperation. java vs. ArrayOperations. java http://www. cs. wcupa 4/11/2019
Every thing under the control inside of object (which must be declared in the class) 4/11/2019
state: String name, breed int age Dog class state: String name, breed int age behavior: writeOutput ( ) getAgeInHumanYears ( ) Point object balto state: “Balto” (name) 8 (age) “Siberian Husky” (breed) behavior: getAgeInHumanYears ( ) writeOutput ( ) Point object scooby state: “Balto” (name) 8 (age) “Siberian Husky” (breed) behavior: getAgeInHumanYears ( ) writeOutput ( )
Declaration (signature part) and call Constructor When it is called? Name No return Not static Related to the use of new Overloading 4/11/2019
Mutator Accessor toString Argument and parameter Order and type (compatible & overloading) Primitive type and reference type (array & object) Accessor Return toString 4/11/2019
Access and Scope Attribute (property, data field, etc) Local variable & parameter What is “this” 4/11/2019