Transcript Strings

Strings
A string is a sequence of characters that is treated as a
single value.
We have been using strings all along. For example
System.out.println("Hello, how are you?");
Blotgrunge ... out to reality ... HelloWorld.java
Blitititi … out to reality … StringVar.java
Blitititi … out to reality … StringVar3.java
Concatenating Strings
The + operator concatenates strings.
A new string object is created - the operands are not
affected. Old strings are garbage collected.
Gadzook … out to reality … StringCat.java
Note that System.out.print really does this, not
“and also print”.
Gadzook … back to reality … StringVar3.java
Reading Strings
The Scanner next() method reads the next word of
input.
The Scanner nextLine() method reads the next line of
input.
Rootlepoo… out to reality … StringScanner.java