5-11 ReturnString
Post date: Apr 3, 2014 4:14:17 PM
/*
This program demonstrates a method that
returns a reference to a String object.
*/
package returnstring;
public class ReturnString
{
public static void main(String[] args)
{
String customerName;
customerName = fullName("John","Martin");
System.out.println(customerName);
}
/*
The fullName method accepts two String arguments
containing a first and last name. It concatenates
them into a single String object.
@param first The first name,
@param iast The last name.
@return A reference to a String object containing
the first and last names.
*/
public static String fullName(String first , String last)
{
String name;
name = first + " " + last;
return name;
}
}