java eclipse编译器报错 The import java.lang.String conflicts with a type defined in the same file解决方案

java eclipse编译器报错 The import java.lang.String conflicts with a type defined in the same file解决方案

使用eclipse编码时遇到一个问题
import java.lang.String;后String str = “how are you doing this?”; 报错
如下图
java eclipse编译器报错 The import java.lang.String conflicts with a type defined in the same file解决方案
java.lang.String报错
java eclipse编译器报错 The import java.lang.String conflicts with a type defined in the same file解决方案
String str = “how are you doing this?”; 报错

原因:类名String和java.lang.String冲突导致编译器无法识别

解决方案:更改类名String(当然同时也应更改String.java)
如下图
java eclipse编译器报错 The import java.lang.String conflicts with a type defined in the same file解决方案
程序无报错,可正常编译,问题解决