File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "code for writing full-name" Watch "code for writing full-name" New topic

code for writing full-name

Booba Degouv

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

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]
I agree. Here's the link:
subject: code for writing full-name
jQuery in Action, 3rd edition