![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java
qq_31756397
这个作者很懒,什么都没留下…
展开
-
实例变量与局部变量
实例变量是声明在类内而不是方法中 局部变量是声明在方法中的 局部变量在使用前不许初始化原创 2016-08-19 16:00:34 · 546 阅读 · 0 评论 -
多态与覆盖
1.多态 运用多态时,引用类型可以是实际对象类型的父类: Animal myDog = new Dog;Animal[] animals = new Animal[3]; animals[0] = new Dog(); animals[1] = new Cat(); animals[2] = new Wolf(); for(int i =0;i<animals.length;i++){原创 2016-08-20 19:09:18 · 419 阅读 · 0 评论 -
java this 关键字
一、this关键字主要有三个应用: (1)this调用本类中的属性,也就是类中的成员变量; (2)this调用本类中的其他方法; (3)this调用本类中的其他构造方法,调用时要放在构造方法的首行。 Public Class Student { String name; //定义一个成员变量name private void SetName(String name) { //转载 2016-08-11 12:21:12 · 280 阅读 · 0 评论