public class JoinStrings {
/* The process of joining one string to another is called
* concatenation. Java does this in a similar way to most other
* popular languages. And that is to use the + sign in the
* same way as adding two numbers together.
*/
public static void main(String[] args) {
// + sign used for addition.
int result = 1 + 2;
System.out.println("Addition: 1 + 2 = " + result);
// + used to concatenate two strings.
String thing1 = "Joe ";
String thing2 = "Blogs";
String result_string = thing1 + thing2;
System.out.println("Concatenation: thing1 + thing2 = " + result_string);
}
}
No comments:
Post a Comment