char initial = 'p';
Note the single quote. Characters take less time to compare than Strings.
hmmm. Consider the java.lang.Character class . Why is this interesting?
You can see the API for java.lang.Strings and java.lang.StringBuffer .
Read These. Discuss use of static (e.g. valueOf)
Do these need to be imported when used in code?
Strings are immutable. What does this mean?
Because of this, old programmers like to use StringBuffer. Here is an example:
Other methods:
Strings are immutable, but you can make new strings:
string1 = "Mississippi".replace('i','a');
Other methods:
Look at API to see what returns
String buffers are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order.
String buffers are used by the compiler to implement the binary
string concatenation operator +. For example, the code:
x = "a" + 4 + "c"