skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Friday, January 6, 2012

Concatenation of Two String in Java

Posted by Admin at 8:56 AM – 0 comments
 
Here is the Program for  concatenation  of two String



public class Ruler { 
    public static void main(String[] args) { 
        String msg = "My Name is";
        String msg = msg + " Sam";  
    
        System.out.println(msg);
    }

}

/*************************
 * OUTPUT of Program
 * 
 *   My Name is Sam
 ************************/

Explanation of Program
In this example we have taken a String variable 'msg' in which we've assigned the value "My name is" after assigning the value we have concatenated with other String ' Sam' using + Operator.
Labels: Basic Java Programs , Concatenation of String

Leave a Reply

Newer Post Older Post
Subscribe to: Post Comments ( Atom )
  • Popular
  • Recent
  • Archives
Powered by Blogger.
 
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger