且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:不兼容的类型:java.lang.String无法转换为String

更新时间:2023-01-17 20:45:49

因为您的类被命名为 String String city 中的非限定类型引用被视为对您自己的类的引用。

Since your class is named String, unqualified type reference in String city is taken as reference to your own class.

将类重命名为一些其他名称,或者你必须写 java.lang.String ,无论你在哪里引用内置Java String 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.