abstract class Animal{ abstract void eat(); } class Cat extends Animal{ void eat(){ System.out.println("eat fish"); } void catchMouse(){ System.out.pr ...
分类:
其他好文 时间:
2017-07-10 22:07:36
阅读次数:
144
第1章 变量 1.1 计算 1.1.1 基础运算 >>> 1+2 3 >>> 1+2 3 1.1.2 变量运算 >>> eat = 10+15+6 >>> cloth = 20+20 >>> total = eat+cloth >>> print('总消费',total) ('总消费', 71) > ...
分类:
编程语言 时间:
2017-07-06 12:22:06
阅读次数:
215
面向对象的程序设计一(类和对象) 1 ''' 2 对象一 3 name="fang" 4 age=28 5 country="shina" 6 7 技能 8 def talk(self): 9 print("is talking") 10 11 def eat(self): 12 print("is ...
分类:
其他好文 时间:
2017-07-03 19:12:34
阅读次数:
199
1.做一个饲养员给动物喂食物的样例体现JAVA中的面向对象思想,接口(抽象类)的用处 package com.softeem.demo; /** *@authorleno *动物的接口 */ interface Animal { public void eat(Food food); } /** * ...
分类:
编程语言 时间:
2017-07-02 13:46:53
阅读次数:
216
1.实现前置增强 必须实现接口MethodBeforeAdvice接口 创建对应的文件 public interface Animal {//主业务接口 void eat(); //目标方法 void sleep(); } public class Dog implements Animal {// ...
分类:
编程语言 时间:
2017-06-30 09:47:53
阅读次数:
198
构造函数 1.构造函数方法很好用,但是存在一个浪费内存的问题 2.Prototype模式,所有实例的type属性和eat()方法,其实都是同一个内存地址,指向prototype对象,因此就提高了运行效率。 ...
分类:
编程语言 时间:
2017-06-27 15:00:44
阅读次数:
131
原文出处: 五月的仓颉 为什么Spring要支持Autowire(自动装配) 先写几个类,首先定义一个Animal接口表示动物: 1 2 3 4 5 public interface Animal { public void eat(); } 1 2 3 4 5 public interface A ...
分类:
编程语言 时间:
2017-06-25 23:07:11
阅读次数:
277
#继承实现#父亲会书法,大儿子和小儿子会书法#父亲一般能吃,大儿子吃超过,小儿子吃得少class father: def write(self): print 'i can write'class oldbrother(father):#class A(B)子类A继承父类B def eat(self ...
分类:
编程语言 时间:
2017-06-25 16:11:57
阅读次数:
119
Java向上转型和向下转型(附具体样例) 熬夜整理的关于Java向上和向下转型的样例,很的通俗易懂哦~~~~ 一.向上转型 package com.sheepmu; class Animal { public void eat() { System.out.println("父类的 eating.. ...
分类:
编程语言 时间:
2017-06-23 23:03:27
阅读次数:
287
匿名内部类也就是没有名字的内部类 正因为没有名字,所以匿名内部类只能使用一次,它通常用来简化代码编写 但使用匿名内部类还有个前提条件:必须继承一个父类或实现一个接口 实例1:不使用匿名内部类来实现抽象方法 运行结果:eat something 可以看到,我们用Child继承了Person类,然后实现 ...
分类:
编程语言 时间:
2017-06-18 20:00:55
阅读次数:
165