在学习StringBuffer过程中出现这种编译错误:“The constructor StringBuffer(String) is undefined”,在查询后得到如下结果:
但是,按照所建议的加上包名“java.lang.StringBuffer”后,仍显示编译错误:
“The import java.lang.StringBuffer conflicts with a type defined in the same file”。
我认为两个报错原因都是因为:类名和StringBuffer冲突导致编译器无法识别,最直接的方法就是更改类名。