[英]String implement in Oracle JDK and OpenJDK
I found the definition about String:我找到了关于 String 的定义:
String
in Oracle Jdk
extends Object
but Open Jdk
doesn't Oracle Jdk
String
extends Object
但Open Jdk
不extends Object
And when i create an example code with generic type as:当我创建一个具有泛型类型的示例代码时:
public void testMethod(Map<String,?> map)
Map<String,String> tmpMap = new HashMap<String, String>();
tmpMap.put("Test", "Test");
testMethod(tmpMap);
it compile and run without any errors on two platforms.它在两个平台上编译和运行都没有任何错误。
? ? in Generic
is any types which extends from Object
在Generic
是从Object
扩展的任何类型
So my question is:所以我的问题是:
See also:也可以看看:
The Java Language Specification says Java 语言规范说
The class
Object
is a superclass (§8.1.4) of all other classes.Object
类是所有其他类的超类(第 8.1.4 节)。
So a class declared as所以一个类声明为
public class SomeType
is actually equivalent to实际上相当于
public class SomeType extends Object
So the String
class from your OpenJDK Java 7 link所以你的 OpenJDK Java 7 链接中的String
类
public final class String implements java.io.Serializable, Comparable<String>, CharSequence
is actually equivalent to实际上相当于
public final class String extends Object implements java.io.Serializable, Comparable<String>, CharSequence
So that satisfies the Javadoc in the Oracle link.这样就满足了 Oracle 链接中的 Javadoc。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.