Q:

Write a Java Program to Copy String into Another String

belongs to collection: Java String Solved Programs

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java String Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Java Program to Append(Concatenate) one string to ... >>
<< Write a Java Program to reverse any String...