Lecture 5 Java Classes 1
Lecture 5 Java Classes 1
Modifiers
public
The primary class The identifier is the same as the filename
Private
The supporting class Classes accessible only within the file
Matching Parameters
Parameters refers to the list of variables in a method declaration Arguments are the actual values that are passed in when the method is invoked. No. of Arguments Data type of each argument must match
Casting can be used to match arguments for different objects as long as they are compatible (is a relationship)
Passing Objects
Passing hadles/reference Simple Readable Flexible
Constructor
Used to create an instance of a class and initializes the instance variables Contructor name is the same as the class name Default constructor has no parameter Default contructor is only created if there is no constructors It has no return type (not even void) The super() is used to call the superclass constructor.
static
Reserve word / modifier used to declare class variables
Instance variables
Class local variables Values are different in each instance