Question:
How do you convert a whole string to the upper case values?
Answer:
Using the String toUpperCase() method.
Code:
public class UpperCase { public static void main(String[] args) { String str = "abcdef ghijkl mnopqr stuvwxyz"; String up = str.toUpperCase(); System.out.println("Original string: " + str); System.out.println("Upper case: " + up); } }
Output:
$ java UpperCase Original string: abcdef ghijkl mnopqr stuvwxyz Upper case: ABCDEF GHIJKL MNOPQR STUVWXYZ