This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes code for writing full-name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "code for writing full-name" Watch "code for writing full-name" New topic
Author

code for writing full-name

Booba Degouv
Greenhorn

Joined: Aug 20, 2002
Posts: 3
Hello, i have a class "Person" with the attributes:

firstname - a String first name
surname - a String surname
But i need to know how to write a method for fullname; which returns a string containing firstname and surname separated by a space.
Its probably really simple, but i dont know how to? any suggestions?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
The method you're supposed to come up with probably involves String concatenation. For a definition of concatenate, take a look at this, this, and this.
For example:
String a = "a";
String b = "b";
String ab = a + b;
String ab would then be "ab".
For more information and a better explanation, take a look at Chapter 29 of Bradley Kjell's Introduction to Computer Science using Java.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
wood burning stoves
 
subject: code for writing full-name
 
Similar Threads
help printing information
help with loop
Any defect in the attached code
Help Please
Searching for employee details in the MySQL database