Scala Programming: Convert all the characters in a string to lowercase, uppercase
Scala Programming String Exercise-12 with Solution
Write a Scala program to convert all the characters to lowercase, uppercase strings.
Sample Solution:
Scala Code:
object Scala_String {
def main(args: Array[String]): Unit = {
val str ="The Quick BroWn FoX!";
// Convert the above string to all lowercase.
val lowerStr = str.toLowerCase();
val upperStr = str.toUpperCase();
// Display the two strings for comparison.
println("Original String: " + str);
println("String in lowercase: " + lowerStr);
println("String in uppercase: " + upperStr);
}
}
Sample Output:
Original String: The Quick BroWn FoX! String in lowercase: the quick brown fox! String in uppercase: THE QUICK BROWN FOX!
Scala Code Editor :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous:Write a Scala program to get a substring of a given string between two specified positions.
Next: Write a Scala program to trim any leading or trailing whitespace from a given string.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework