java / beginner
Snippet
String Case Conversion
Java Strings are objects that come with built-in methods. The toUpperCase() method creates a new String with all letters converted to capitals.
snippet.java
1
2
String lower = "java";String upper = lower.toUpperCase();
Breakdown
1
String lower = "java";
Declares a String variable in lowercase.
2
String upper = lower.toUpperCase();
Calls the method to convert the text to uppercase and assigns the result to 'upper'.