舉個例子,如下,找妳們開發解bug把。
List<Object> list = new ArrayList<>();
Long l = 1L;
list.add(l);
String s = (String) list.get(0);
運行這段代碼就會拋出妳那個異常:
java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.String (java.lang.Long and java.lang.String are in module java.base of loader 'bootstrap')