COSI 11a Chapter Notes - Chapter 3: Substring

96 views2 pages
Chapter 3 Outline
Introduction to Parameters and Objects
Pages 132 – 187
I. Parameters
A. Mechanics of Parameters
1. The formal parameter is the parameter that appears in the method header and the actual
parameter appears in the method call. The word argument sometimes refers to the actual
parameters.
II. Using Objects
A. String Objects
1. An object stores data (state) and methods (behaviors).
2. To call an object’s method the variable’s name is followed by a dot and the method’s name.
For example, to call a String s’s length method: s.length() is used. The general syntax is:
<variable>.<method name>(<expression>).
3. The substring method ends at the index before the 2nd value used. For example,
String s = “dancing”;
s.substring(0,3) is “dan” and not “danc”.
B. Scanner Objects
1. Constructors are called using the keyword new, followed by the object’s type and any needed
parameters.
2. To read an input stream use:
Scanner console = new Scanner(System.in);
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions