Page 299 - ComputerScience_Class_11
P. 299
The output of the preceding program is as follows:
BlueJ: Terminal Window - Java
Options
The index value is: 15
The toLowerCase() Function
As the name itself suggests, this function converts all the characters of a string to lowercase letters. However, for any
letters written in lowercase, there will be no change in the output. The syntax is:
String <variable> = String_datatype_Variable.toLowerCase();
Let us see the below example:
Program 7 Write a program to convert the string to lowercase and display the result.
1 class string_count
2 {
3 public static void main(String[] args)
4 {
5 String str= "KOLkatA - 700114";
6 String changestr= str.toLowerCase();
7 System.out.println("The converted string is: " +changestr);
8 }
9 }
The output of the preceding program is as follows:
BlueJ: Terminal Window - Java
Options
The converted string is: kolkata - 700114
The toUpperCase() Function
This method converts all the characters of a string to uppercase letters. However, for the letters already in uppercase,
there will be no change in the output. The syntax is:
String <variable> = String_datatype_Variable.toUpperCase();
Let us see the below example:
Program 8 Write a program to convert the string to uppercase and display the result.
1 class string_count
2 {
3 public static void main(String[] args)
4 {
5 String str= "KOLkatA - 700114";
Strings 297

