lec16Feb808

lec16Feb808 - What is the scope of a variable? Region of a...

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

View Full Document Right Arrow Icon
Lecture 16 February 8, 2008
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Data Scope The scope of data is the area in a program in which that data can be used (referenced) Member variables ( instance variables and static variables) can be used by all methods of the class Note: static methods can only use static variables Data declared within a method (i.e. local data) can only be used in that method
Background image of page 3

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

View Full DocumentRight Arrow Icon
To Err or not to Err? public int subtractOne(int inputValue)   { return inputValue--;   }     System.out.println(“Current Value:” + inputValue);
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: What is the scope of a variable? Region of a program within which the variable can be referred to by its simple name Why do we care? Scope determines when the system creates and destroys memory for the variable How do you determine the scope? Location of the variable declaration within your program establishes its scope: Member variables Method parameter Local variable...
View Full Document

This note was uploaded on 04/14/2008 for the course COMP 202 taught by Professor Verbrugge during the Winter '07 term at McGill.

Page1 / 5

lec16Feb808 - What is the scope of a variable? Region of a...

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

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