Professional Documents
Culture Documents
AP Computer Science - Classes, Objects, Methods: Class
AP Computer Science - Classes, Objects, Methods: Class
Method1
What things will the OBJECT know? What things will the OBJECT do? Example: An object is like ONE entry in an address book. Each entry has the same structure, but different data. The data can be changed (e.g., phone number change, address change, etc.) An object consists of METHODS that contain a set of instructions that use the data (what the object knows) to perform an action (what the object does).
PrintStream
String
println print
length
toUpperCase
replace
Examples:
int n = greeting.length();
Output = ?? How would you print the uppercase version of Hello, World! System.out.println(greeting.toUpperCase());
A parameter is an INPUT to the method. Some methods require multiple parameters, others require none at all, e.g., the length() method.