fork(1) download
  1. import java.util.Scanner; // Needed for the Scanner class
  2. class StringManipulator
  3. {
  4. public static void main(String[] args)
  5. {
  6. String city; // To hold user input
  7. Scanner keyboard = new Scanner(System.in);
  8. System.out.print("Enter the name of your favorite city: ");
  9. city = keyboard.nextLine();
  10. System.out.println("Number of characters: " + city.length());
  11. System.out.println(city.toUpperCase());
  12. System.out.println(city.toLowerCase());
  13. System.out.println(city.charAt(0));
  14. }
  15. }
Success #stdin #stdout 0.15s 51640KB
stdin
Kekirawa 
stdout
Enter the name of your favorite city: Number of characters: 9
KEKIRAWA 
kekirawa 
K