char c = 'a'; c = Character.toUpperCase(c); System.out.println(c); // Output: A
String str = "hello world"; char[] chars = str.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (Character.isLowerCase(c)) { chars[i] = Character.toUpperCase(c); } } str = new String(chars); System.out.println(str); // Output: HELLO WORLDIn the above example, we start with a lowercase string 'hello world'. We first convert the string to a char array using the toCharArray() method. We then loop through each character in the array, and if the character is lowercase, we use the toUpperCase() method to convert it to uppercase and replace the original character in the array. Finally, we create a new String object using the modified character array and print it to the console. Package library: java.lang package.