lecture13 - Computer Science 65 Intro to CS March 11, 2008...

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

View Full Document Right Arrow Icon
Computer Science 65 Intro to CS March 11, 2008 Methods (Chapter 5.1-5.4) Scope Local Variables
Background image of page 1

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

View Full DocumentRight Arrow Icon
Presentations March 11 Angela Bys education/computers in the classroom March 13 David Ehresmann Molecular modeling
Background image of page 2
Announcements Exam #1 Average: 68.15 (out of 76) Hand back at the end of class No Office Hours Wednesday, March 12th
Background image of page 3

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

View Full DocumentRight Arrow Icon
Multiple Parameters Methods can contain more than one parameter public static void printSum(int x, int y) { System.out.println(x+y); }
Background image of page 4
Multiple Parameters Example public class Example { public static void main(String[] args) { printSum(4,5); } public static void printSum(int x, int y) { System.out.println(x+y); } }
Background image of page 5

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

View Full DocumentRight Arrow Icon
Variables within Methods Variables declared within a method are called _____________ The scope of a local variable is limited to the method public static void printSum(int x, int y) { int sum = x + y; System.out.println(sum); }
Background image of page 6
Scope A variable’s scope is
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
Returning a Value from a Method Data can be passed into a method by way of the parameter variables. Data may also be returned from a method, back to the statement that called it. int num = Integer.parseInt("700");
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/02/2008 for the course CS 065 taught by Professor Urness during the Spring '08 term at Drake University .

Page1 / 30

lecture13 - Computer Science 65 Intro to CS March 11, 2008...

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

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