public class 12.java {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the name of your favorite city: ");
String city = keyboard.nextLine();
keyboard.close();
System.out.println("Number of characters: " + city.length());
System.out.println(city.toUpperCase());
System.out.println(city.toLowerCase());
System.out.println(city.charAt(0));
}
}
Asked
Active
Viewed 196 times
-2

Bohemian
- 412,405
- 93
- 575
- 722

Tomas Perez
- 1
- 1
-
1That's not a valid class name. It can't begin with a number – DontKnowMuchBut Getting Better Jul 04 '20 at 18:43
-
1and it can't contain a dot – Andrew Tobilko Jul 04 '20 at 18:45
-
And "what's wrong?" is not the type of questions that are appreciated here. Please, next time try to elaborate on the problem, show what you have tried, why you think it should work. – Andrew Tobilko Jul 04 '20 at 18:47
-
@DontKnowMuchButGettingBetter fixing starting with a number is not enough; there’s also the “.java” part to fix. – Bohemian Jul 04 '20 at 18:48
-
@Bohemian fair enough, though to be honest, I'm not sure if this Q/A will help future visitors all that much – DontKnowMuchBut Getting Better Jul 04 '20 at 18:49
1 Answers
2
“12.java” is not a valid java class name, which must start with a letter followed by either letters or numbers (underscores are considered to be letters).
Change it to something that starts with a letter (normally a capital letter) and does not have a dot, eg:
public class Twelve

Bohemian
- 412,405
- 93
- 575
- 722