We can use .substring(start,end) to copy part of a String.
We can use indexOf( String ) to find a small String in a larger one.
Assume that name contains "Jones, Fred" or some
other name,
in the format "Last, First".
Write a method that accepts name as a parameter,
uses
indexOf to locate the comma, then uses
substring
to copy the first name that
is following the comma.
Notice that there is also a blank space after the
comma.
public String firstName(String
name)
{
int c =
name.indexOf(","); // position of
the comma
String first = name.substring( c + 1 , name.length()
);
return first;
}