Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code for writing full-name

 
Booba Degouv
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic