lecture4 - PIC 20A Lecture 4: Variables, this, Number...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
PIC 20A Lecture 4: Variables, this , Number Problems, Casting, Constants, Static Methods
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
3 Roles for Variables 1. member variables (fields) 2. local variables 3. method parameters
Background image of page 2
Member Variables (Fields) • declared in the body of the class definition but not in the body of any method • visible or accessible inside any method of the class • automatically assigned a default value (whatever represents zero for that type) • every object of a class has its own set of them • should usually be private or protected • constants are usually public and static
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Local Variables defined in the body of a method must be initialized before being used visible or accessible only in the method in which it is defined die when method returns do not have access control specifiers such as public , protected , or private
Background image of page 4
Method Parameters • defined in the method’s parameter list • initialized by arguments supplied in the method call • visible or accessible only in the method in which it is defined • die when method returns • do not have access control specifiers such as public , protected , or private
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
A non-static method has •A n implicit parameter (the calling object or the object being constructed)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/12/2010 for the course PIC PIC 20A taught by Professor Keithouellette during the Spring '09 term at UCLA.

Page1 / 18

lecture4 - PIC 20A Lecture 4: Variables, this, Number...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online