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

String Functions

The document contains a Java class named StringOperations that demonstrates various string manipulation methods. It concatenates two strings, 'Hello' and 'World', and prints the concatenated result along with its length, uppercase and lowercase versions, a substring, a character at a specific index, a check for substring presence, and a replacement of a substring. This serves as a basic example of string operations in Java.

Uploaded by

Srimathi tj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

String Functions

The document contains a Java class named StringOperations that demonstrates various string manipulation methods. It concatenates two strings, 'Hello' and 'World', and prints the concatenated result along with its length, uppercase and lowercase versions, a substring, a character at a specific index, a check for substring presence, and a replacement of a substring. This serves as a basic example of string operations in Java.

Uploaded by

Srimathi tj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

public class StringOperations {

public static void main(String[] args) {


String str1 = "Hello";
String str2 = "World";

String concatenated = str1 + " " + str2;


System.out.println("Concatenated: " + concatenated);

System.out.println("Length: " + concatenated.length());


System.out.println("Uppercase: " + concatenated.toUpperCase());
System.out.println("Lowercase: " + concatenated.toLowerCase());
System.out.println("Substring (0-5): " + concatenated.substring(0, 5));
System.out.println("Char at index 1: " + concatenated.charAt(1));
System.out.println("Contains 'World': " + concatenated.contains("World"));
System.out.println("Replaced 'World' with 'Java': " +
concatenated.replace("World", "Java"));
}
}

You might also like