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

后端 未结 3 1807
南笙
南笙 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:36

    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.

提交回复
热议问题