CSCE 3193 Lecture Notes - Lecture 3: Instance Variable, Decimal Mark, Default Constructor
Document Summary
Classes system and string are in package java. lang. Classes that are compiled in same directory on disk are in the same package-default package import declaration not required if always refer to class via its fully qualified class name. Example: import java. util. arraylist(tells compiler where to find stuff) Class normally consists of one or more methods that manipulate attributes the belong to object. Attributes-fields-declared inside class, outside bodies of class"s methods. Instance variable each object maintains its own copy of an attribute. Example:public class gradebook{ private string coursename; //maintains its own copy of instance variable coursename public void setcoursename( string name) //allows client code to change coursename. Return coursename;} //allows client code to obtain coursename. //allows you to protect your class and stay classy san diego. Public void displaymessage(){ //no parameter because all methods in class already know. Every instance(object) of a class contains one copy of each instance variable.