-
Inside the main
method, create a string variable named inputString
and initialize it with any string of your choice.
String inputString = "HELLO";
-
Create a character array named charArray
and initialize it by converting inputString
to a character array using the toCharArray()
method.
char[] charArray = inputString.toCharArray();
-
Use a for loop to iterate through each character in the charArray
.
for(int i=0; i<charArray.length; i++){
}
-
Inside the for loop, invoke the toLowerCase()
method and pass the current character of the charArray
as a parameter.
char lowercaseChar = Character.toLowerCase(charArray[i]);
-
Print the lowercase character to the console.
System.out.print(lowercaseChar);
-
Save the file and exit the editor.