1. Home
  2. Computing & Technology
  3. Java

Concatenation

By , About.com Guide

Definition:

Concatenation describes the operation of joining two strings together. In Java, the operator "+" normally acts as an arithmetic operator unless one of its operands is a String. If necessary it converts the other operand to a String before joining the second operand to the end of the first operand.

Examples:

To join the two Strings "pan" and "handle":

System.out.println("pan" + "handle");

If one of the operands is not a String it will be converted:

int age = 12;
System.out.println("My age is " + age);

There is also a method called concat defined in the String class that performs the same operation:

System.out.println("pan".concat("handle"));

Glossary:

# A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Explore Java
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Java
  4. Java Glossary
  5. C
  6. Concatenation - Definition for the Java Term: Concatenation>

©2010 About.com, a part of The New York Times Company.

All rights reserved.