Here is an example of a Java program that meets the requirements:
import java.util.Scanner;
public class FavoriteCity {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String city;
System.out.print("Enter your favorite city: ");
city = input.nextLine();
System.out.println("Number of characters in the city name: " + city.length());
System.out.println("City name in uppercase letters: " + city.toUpperCase());
System.out.println("City name in lowercase letters: " + city.toLowerCase());
System.out.println("First character in the city name: " + city.charAt(0));
}
}
In this example, the Scanner class is used to retrieve input from the user. The user is prompted to enter their favorite city, and the input is stored in a String variable named city. The length of the city name is obtained using the length() method, the city name in uppercase letters is obtained using the toUpperCase() method, the city name in lowercase letters is obtained using the toLowerCase() method, and the first character in the city name is obtained using the charAt(0) method. The results are displayed to the user using println statements.