error: incompatible types: java.lang.String cannot be converted to String

后端 未结 3 1794
南笙
南笙 2021-01-27 07:22

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         


        
3条回答
  •  难免孤独
    2021-01-27 07:40

    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.

提交回复
热议问题