
马士兵
ztao2333
这个作者很懒,什么都没留下…
展开
-
继承中的构造方法
[img]http://dl2.iteye.com/upload/attachment/0116/1316/a5fe1bb2-9c1d-3d63-ad49-90e3ad000663.jpg[/img][img]http://dl2.iteye.com/upload/attachment/0116/7655/431036ab-48bd-3bbf-928c-0a6844e022c2.jpg[/...原创 2016-04-18 11:21:54 · 87 阅读 · 0 评论 -
static关键字
ystem.out.println("My name:"+name+"no:"+id); } public static void main(String args[]){ Test.sid = 100; Test mimi = new Test("mimi"); mimi.sid = 200;//存在同一块内存 data seg Test pipi = new Test("pipi");原创 2016-03-28 01:36:49 · 68 阅读 · 0 评论 -
构造函数,堆栈
。[/size][/color][/b][img]http://dl2.iteye.com/upload/attachment/0116/1304/97cad7db-5650-36bf-98e7-d23fe4a4a555.jpg[/img][img]http://dl2.iteye.com/upload/attachment/0116/1306/0c5654ce-ff4f-361d-9bc4-5325b7f19a1f.jpg[/img][img]http://dl2.iteye.co原创 2016-03-28 01:03:00 · 160 阅读 · 0 评论 -
this关键字
is; } void print(){System.out.println("i="+i);}}public class Test { public static void main(String args[]){ Leaf leaf = new Leaf(100); leaf.increament().increament().print(); }}[/code][img]http://dl2.iteye.com/upload/attac原创 2016-03-28 00:57:48 · 91 阅读 · 0 评论 -
super关键字
public int value; public void f(){ super.f(); value = 200; System.out.println("ChildClass.value="+value); System.out.println(value); System.out.println(super.value); }}public class Test { public static void main(String原创 2016-03-28 00:36:44 · 90 阅读 · 0 评论 -
继承,权限控制
ds Person{ private String school; public void setSchool(String school) { this.school = school; } public String getSchool() { return school; }}public class Test { public static void main(String args[]){ Student student = new Student原创 2016-03-28 01:04:46 · 186 阅读 · 0 评论 -
多态,动态绑定
结构,直接加上就可以了。[color=red]多态的存在必要条件:1:要有继承,2:要有重写,3:父类引用指向子类对象。[/color][code="java"]package test;class Animal{ private String name; Animal(String name){this.name = name;} public void enjoy(){ System.out.println("叫声");原创 2016-03-27 23:29:02 · 66 阅读 · 0 评论 -
static关键字
[code="java"]package test; public class Test{ private static int sid = 0; private String name; int id; Test(String name){ this.name = name; id = sid++; } public void info(){ S...原创 2016-03-28 01:36:49 · 108 阅读 · 0 评论 -
继承,权限控制
[code="java"]package test;class Person{ private String name; public String getName() { return name; } public void setName(String name) { this.name = name; }}class Student exten...原创 2016-03-28 01:04:46 · 110 阅读 · 0 评论 -
构造函数,堆栈
[img]http://dl2.iteye.com/upload/attachment/0116/1302/455b045a-a8fe-3562-8183-eabfda64b0c0.jpg[/img][b][color=red][size=medium]局部变量(tom)永远在栈里(stack),成员变量在堆里(heap)。[/size][/color][/b][img]http:...原创 2016-03-28 01:03:00 · 275 阅读 · 0 评论 -
this关键字
[code="java"]package test;class Leaf{ int i = 0; //this是指向自身的引用,所以this.i是成员变量,i是形参。 Leaf(int i){this.i = i;} Leaf increament(){ i++; return this; } void print(){System.out.println(...原创 2016-03-28 00:57:48 · 76 阅读 · 0 评论 -
super关键字
[code="java"]package test;class FatherClass{ public int value; public void f(){ value = 100; System.out.println("FatherClass.value="+value); }}class ChildClass extends FatherClass{...原创 2016-03-28 00:36:44 · 84 阅读 · 0 评论 -
多态,动态绑定
调用方法时,只要方法重写了,实际当中调哪个,要看实际中new哪个对象。[color=red]好处:可扩展性达到最好。[/color]当增加东西时,不需要改原来的结构,直接加上就可以了。[color=red]多态的存在必要条件:1:要有继承,2:要有重写,3:父类引用指向子类对象。[/color][code="java"]package test;class Anim...原创 2016-03-27 23:29:02 · 99 阅读 · 0 评论 -
继承中的构造方法
img][code="java"]package test; class SuperClass{ private int n; SuperClass(){//构造方法 System.out.println("SuperClass()"); } SuperClass(int n){//重载的构造方法 System.out.println("SuperClass("+n+")");原创 2016-04-18 11:21:54 · 97 阅读 · 0 评论