Java-String Concatenation

String Concatenation

Java defines one operator for string object such as “+”, it is used to concatenate two string. For example, in the following program, the value of the variable ‘date’,’month’ and ‘year’ is being converted to a string that represents this value as a decimal digit character. This is prompted by the fact that it is combined with the string literal, “ “, using the + operator.


string concatenation output

Program Source

public class Javaapp {

    public static void main(String[] args) {
        byte date = 15;
        byte month = 10;
        short year = 1990;
        String dob = new String("Birthday "+date+" / "+month+" / "+year);

Leave a Comment