Text Processing in Java

Literal Characters

A literal character is delimited by single quotes.

Characters can be classified as letters (upper and lower case), digits, punctuation, operators, and control characters.

Back slash is the escape character.

See TestChar.java

Literal Strings

Strings are sequences of characters bracketed by double quotes.

Strings can be appended using the + operator.

See TestString1.java

Strings are Objects

Like most objects, a string object can execute methods. The methods a string object can executed are documented at:

http://java.sun.com/javase/6/docs/api/

These methods include:

Indexing and length methods

Methods for inspecting and replacing substrings

See TestString2.java

Projects

Project 1

Write a Java program that allows a user to type in simple arithmetical expressions of the form:

<Number> + <Number>

Your program computes and displays the sum.

Hint: Use Java's Scanner class in the java.util package to read input from the user:

java.util.Scanner keyboard = new java.util.Scanner(System.in);