Thursday, December 24, 2015

String Concatenation:

String Con:catenation
Here is a small java program to demonstrate String Concatenation:

package stringdemo;


public class StringConcat {
    public static void main(String[] args) {
        String age="19";
        String s= "I am"+ age +"years old";
        System.out.println(s);
       
       
        //Using concatenation to prevent long lines.
       
        String str="I want to say u that"+"I love you";
        System.out.println(str);
    }
}
The output of this Program is shown below:


I am19years old
I want to say u thatI love you

0 comments:

Post a Comment