Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create Concatenate string in java

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 199
    Comment on it

    With the help of java, I have created concat() string method. In the example given below, I have used '+' operator , StringBuilder and StringBuffer Class to join string in java. The string concat() method combines specified string at the end of the primary string and returns combined string.

    public class StringConcat{
    
        public static void main(String args[]) {
    
            String firstname = "Raj";
            String lastname = "Tiwari";
    
            //  concatenate String      
            String name = firstname + " " + lastname;
            System.out.println(name);
    
    
            //  using StringBuilder
            StringBuilder sb = new StringBuilder(14);
            sb.append(firstname).append(" ").append(lastname);
            System.out.println(sb.toString());
    
    
            //  using StringBuffer
            StringBuffer sBuffer = new StringBuffer(15);
            sBuffer.append(firstname).append(" ").append(lastname);
            System.out.println(sBuffer.toString());
    
        }     
    
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: