我正在上大学的Java课程,并正在处理一些特定的任务.这是我为它写的代码.
public class String
{
public static void main(String[] args)
{
String city = "San Francisco";
int stringLength = city.length();
char oneChar = city.charAt(0);
String upperCity = city.toUpperCase();
String lowerCity = city.toLowerCase();
System.out.println(city);
System.out.println(stringLength);
System.out.println(oneChar);
System.out.println(upperCity);
System.out.println();
}
}
Run Code Online (Sandbox Code Playgroud)
这产生了这些结果
C:\Users\sam\Documents\Java>javac String.java
String.java:8: error: incompatible types: java.lang.String cannot be
converted to String
String city = "San Franciso";
^
String.java:9: error: cannot find symbol
int stringLength = city.length();
^
symbol: method length()
location: variable city of type String
String.java:10: error: cannot …Run Code Online (Sandbox Code Playgroud) java ×1