我使用 red5 并使用 IConnection 类设置/获取属性,但这真的不相关。
'L'在java中表示long。所以 0L 是 0 类型 Long 而不是只是 '0' 这是 0 类型 Integer。
下面的错误信息中[Ljava.lang.Long
和java.lang.Long
有什么区别:
stack trace: java.lang.ClassCastException: [Ljava.lang.Long; cannot be cast to java.lang.Long
更新
代码示例:
static Long getLongAttribute(IConnection conn, String attribute) {
Long result=null;
try {
if (!conn.hasAttribute(attribute))
throw new Exception(attribute + " - Long attribute not found!");
result = conn.getLongAttribute(attribute); // <--- ERRROR ON THIS LINE
} catch (Exception e) {
_handleException(e);
}
return result;
}
最佳答案
第一个对象是Long
数组,第二个对象只是Long
。试试这个
Long l = 1l;
Long[] l2 = {};
System.out.println(l.getClass());
System.out.println(l2.getClass());
输出
class java.lang.Long
class [Ljava.lang.Long;
但我同意 [L_class_;
数组类型的表示非常困惑。我想知道它是怎么变成那样的。
关于java: ClassCastException - [Ljava.lang.Long;无法转换为 java.lang.Long,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4510354/