I'm taking a Java class for college, and was working on some given tasks. This is the code I wrote for it.
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();
}
}
which yielded these results
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 find symbol
char oneChar = city.charAt(0);
^
symbol: method charAt(int)
location: variable city of type String
String.java:11: error: cannot find symbol
String upperCity = city.toUpperCase();
^
symbol: method toUpperCase()
location: variable city of type String
String.java:12: error: cannot find symbol
String lowerCity = city.toLowerCase();
^
symbol: method toLowerCase()
location: variable city of type String
5 errors
I've tried searching for an answer but I didn't really find anything that helps. Any help is appreciated, thanks.
String.public class Stringto something else