belongs to collection: Java String Solved Programs
Java Program to copy string in Java Programming, you have to ask to the user to enter the string to make copy to another variable say strCopy and display this variable which is the copied value of the given string as shown in the following program.
SOURCE CODE ::
import java.util.Scanner; public class Copy_String { public static void main(String args[]) { String strOrig; Scanner scan = new Scanner(System.in); System.out.print("Enter a String : "); strOrig = scan.nextLine(); System.out.print("Copying String...\n"); StringBuffer strCopy = new StringBuffer(strOrig); System.out.print("String Copied Successfully..!!\n"); System.out.print("The Copied String is " + strCopy); } }
OUTPUT ::
Enter a String : Codezclub Copying String... String Copied Successfully..!! The Copied String is Codezclub
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
SOURCE CODE ::
OUTPUT ::
need an explanation for this answer? contact us directly to get an explanation for this answer