...

/

Programs of String Operations

Programs of String Operations

Implement string and set operations on the arrays.

Copy a string

In Java, the individual characters in a string can be accessed but not assigned or modified.

The following program copies a string to another string:

Press + to interact
Press + to interact
class Test
{
public static void main(String args[])
{
String src = "Just a string"; // The string to be copied
int lsrc = src.length();// Calculating the length of src
String dst = ""; // Creating an empty string
dst = src; // Copying data from src to dst
System.out.println("src: " + src);
System.out.println("dst: " + dst);
}
}

String concatenation

Concatenation means appending a string to another string. The following program ...