0% found this document useful (0 votes)
3 views2 pages

Java String Handling Functions Guide

The document is a Java program that demonstrates various string handling functions. It allows the user to input a string and provides functionalities such as calculating the string length, converting it to uppercase and lowercase, checking for a substring, and finding the index of a specific character. The program utilizes the Scanner class for user input and performs operations based on the input provided.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java String Handling Functions Guide

The document is a Java program that demonstrates various string handling functions. It allows the user to input a string and provides functionalities such as calculating the string length, converting it to uppercase and lowercase, checking for a substring, and finding the index of a specific character. The program utilizes the Scanner class for user input and performs operations based on the input provided.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1).

Java Program for string Handling Functions


import [Link];

public class StringHandlingProgram {


public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);

// Get input from the user


[Link]("Enter a string: ");
String input = [Link]();

// Display the length of the string


[Link]("Length of the string: " + [Link]());

// Convert the string to uppercase


String uppercase = [Link]();
[Link]("Uppercase string: " + uppercase);

// Convert the string to lowercase


String lowercase = [Link]();
[Link]("Lowercase string: " + lowercase);

// Check if the string contains a specific substring


[Link]("Enter a substring to search for: ");
String substring = [Link]();
if ([Link](substring)) {
[Link]("String contains the substring.");
} else {
[Link]("String does not contain the substring.");
}

// Get the index of a specific character in the string


[Link]("Enter a character to search for: ");
char ch = [Link]().charAt(0);
int index = [Link](ch);
if (index != -1) {
[Link]("Character found at index " + index);
} else {
[Link]("Character not found in the string.");
}

[Link]();
}
}

You might also like