String APPEND FUNCTION in Java

The append function is used to update the value of object ,string or numbers. We can also update the value of an object with += operator but in this example we used append function. First we declare a bufferstring and store a name in that, after this asked user to write few lines through input stream and then display all stuff with previous string. 

Source Code   


import java.util.Scanner;
public class String_Functions{

public static void main(String[] args) {

Scanner input = new Scanner (System.in);
StringBuffer name = new StringBuffer (" LEP ");
String intro = "";
System.out.println(" Enter Your Feed Back About LEP !");
intro = input.nextLine();
System.out.println();
System.out.println(name.append(intro));
}  
 }

Output of the Program

append function


Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment