Code Snippet: Changing Character Case

From Coder Merlin™

Print characters in uppercase or lowercase

Swift

let string = "For the world is hollow, and I have touched the sky!"
print(string.uppercased())
print(string.lowercased())

Python

string = "For the world is hollow, and I have touched the sky!"
print(string.upper())
print(string.lower())

Bash

#!/bin/bash

string="For the world is hollow, and I have touched the sky!"
echo ${string^^}
echo ${string^l}

Common Lisp

(let ((string "For the world is hollow, and I have touched the sky!"))
  (write-line (string-upcase string))
  (write-line (string-downcase string)))

Java

String string = "For the world is hollow, and I have touched the sky!";
System.out.println(string.toUpperCase()); // "FOR THE WORLD IS HOLLOW, AND I HAVE TOUCHED THE SKY"
System.out.println(string.toLowerCase()); // "for the world is hollow, and i have touched the sky"