0% found this document useful (0 votes)
16 views1 page

Java Program To Perform String Operations Using StringBuffer Class

The Java program demonstrates string operations using character arrays, including converting character arrays to strings, calculating string length, finding a character at a specific index, and concatenating two strings. It initializes two character arrays, converts them to strings, and performs the operations while printing the results. The program showcases basic string manipulation techniques in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Java Program To Perform String Operations Using StringBuffer Class

The Java program demonstrates string operations using character arrays, including converting character arrays to strings, calculating string length, finding a character at a specific index, and concatenating two strings. It initializes two character arrays, converts them to strings, and performs the operations while printing the results. The program showcases basic string manipulation techniques in Java.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

/* Java program to perform string operations using character Array class:

a)String length
b) Finding a character at a particular position
c) Concatenating two strings */
import java.io.*;
public class charray
{
public static void main(String args[])
{
char[] ch1 = { 'J', 'A', 'V', 'A'};
char[] ch2 = { 'P', 'r', 'o', 'g', 'r', 'a', 'm', 'm','i','n','g'};
String str1 = String.valueOf(ch1);
System.out.println("First String(Char Array to String): "+str1);
String str2 = String.valueOf(ch2);
System.out.println("Second String(Char Array to String): "+str2);
int len = str1.length();
System.out.println("Char Array length: " + len);
char ch3 = str2.charAt(5);
System.out.println("Character from " + str2 + " at index " + 5 + " is " + ch3);
String str3=str1.concat(str2);
System.out.println("String Concatenation:"+str3);
}
}

You might also like