Chapter 03 Summary
Creating methods:
public static return_type method_name (type parm1, type parm2)
{
...
...
return expression;
}Calling methods:
object_or_class.method_name(parm1, parm2);
You need the class or object if the method is not in your own class. Then, you need the object if the method needs to know some information that is not passed in.
Math
Creating and using objects like Point
Strings
ex: newString = myOriginalString.toLowerCase();
Also, strings can be put together into another string with the +
ex: newString = string1 + string2;
Scanner object knows: How toread from the screen
Package to import: import java.util.Scanner;
How to create a Scanner for your screen:
- Scanner xxx = new Scanner(System.in);
How to use a Scanner to read from your screen:
- int value1 = keyb.nextInt();
Methods that work on Scanner:
- nextInt()
- nextDouble()
- next() up to next whitespace (delimiter)
- nextLine() up to \n
- useDelimiter() (do not need to know)