- 博客(3)
- 收藏
- 关注
原创 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 332
原创 用Math函数中的random随机数模拟骰子
今天学习遇到了挺好玩的Math函数,更加坚定了我学后端的决心。代码如下public class TestRandom { public static void main(String[] args){ //通过骰子来判断今天的手气如何? int i = (int)(6 * Math.random()) + 1; int j = (int)(6 * Math.random()) +...
2020-03-09 18:02:06 1021
原创 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 4016
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人