如果不用Eclipse,在命令窗口中编译一个最简单的Class类,main方法里面只有一句String s="11";报错为:---------- javac ---------- TMain.java:3: cannot access String bad class file: .\String.class class file contains wrong class: java.lang.String Please remove or make sure it appears in the correct subdirectory of the classpath. public static void main(String args[]) ^ 1 errorOutput completed (1 sec consumed) - Normal Termination把String.class替换成原来的,一切就正常了。
TMain.java:3: cannot access String
bad class file: .\String.class
class file contains wrong class: java.lang.String
Please remove or make sure it appears in the correct subdirectory of the classpath.
public static void main(String args[])
^
1 errorOutput completed (1 sec consumed) - Normal Termination把String.class替换成原来的,一切就正常了。
如果这一假设成立则结论是不要去动JRE规定的标准API。
private String string = null;
private Object yourProperty = null
public MyString(String string) {
this.string = string;
}
public Object getYourProperty() {
}
public void setYourProperty() {
}
// 以下实现所有Stringr的方法,具体实现时用String的实现
public int indexOf()
{
return string.indexOf();
}
...
...
}