Class Notes (1,100,000)
CA (620,000)
U of C (8,000)
CPSC (100)
Lecture 11

CPSC 233 Lecture Notes - Lecture 11: Class Variable


Department
Computer Science
Course Code
CPSC 233
Professor
Leonard Manzara
Lecture
11

This preview shows half of the first page. to view the full 3 pages of the document.
CPSC 233 - 3 Feb Wed
Java Class Fundamentals
The class declaration
- The class is the fundamental programming unit in Java
- General form:
accessKeyword class ClassName(user specified)
{
.
.
.
} (*Give your class a different file)
Fields and Methods
- Are defined inside the class declaration
- Fields (variables)
Instance variables
Are associated with each instance (object) of the class
There may be 0 or more copies of these variables, one for each
object that has been instantiated
Are declared at the top level of the class with the general form:
accessKeyword dataType varName;
- Class variables
Are associated with the class (not with instances)
(i.e.) live at the “factory”
There is only one copy of these variables
Are declared at the top level of the class with the general form:
accessKeyword static dataType varName;
You're Reading a Preview

Unlock to view full version