学习错误集
小鬼馒头
从稍有基础开始学习JAVA,走上后端之路
展开
-
java中对象的向上转型会被屏蔽掉数据
JAVA中父类引用指向子类对象,我们称这个过程为向上转型,向上转型后的父类引用变量只能调用它编译类型的方法,不能调用它运行时类型的方法。下面是测试代码:public class Testpolymorp { public static void main(String[] args){ Animal a = new Animal(); Animal b = new Dog();/...原创 2020-03-15 11:46:49 · 334 阅读 · 0 评论 -
Java数据越界错误:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
今天学习Java数组,做练习“倒叙”的时候,出现了错误,如下错误Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10 at Test2.main(Test2.java:9)代码如下public class Test2 { public static void main(Stri...原创 2020-03-08 18:39:52 · 4057 阅读 · 0 评论