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
It is conflict between system class java.lang.String and your class named String. Rename your class String to say MyString, i.e. replace line:
public class String
with
public class MyString
And rename file String.java containing this class to MyString.java.
You can't name your class String because that is a reserved word similar to double or else.
Here is a list of reserved Java keywords: https://en.wikipedia.org/wiki/List_of_Java_keywords
Since your class is named String
, unqualified type reference in String city
is taken as reference to your own class.
Either rename the class to some other name, or you'll have to write java.lang.String
wherever you reference the "built-in" Java String
class.