学好武功,心法是多么的重要。像是那些练错心法的,比如欧阳锋大叔,心法错了,走火入魔了,死在华山之巅。还有些必先自宫的武功,没准后面一页就说上一页是不需要的。
所以6大原则,或者是7大原则有必要说一下,大家也把心法吃透,才能练好武功啊。
public class Animal {
public void eat() {
System.out.println("eat something");
}
public void sleep() {
System.out.println("sleeping ~~");
}
}
public void eat (String kind) {
if (kind.equals("rabbit")) {
System.out.println("eat some carmine");
}
if (kind.equals("tigger")) {
System.out.println("eat some meat");
}
}
public class Rabbit extends Animal {
public void eat() {
System.out.println("eat some carmine");
}
}
public class Cooker {
public void cook(Potato potato) {
System.out.println("开始做菜了");
System.out.println(potato.getFood());
}
}
class Potato {
public String getFood() {
return "酸辣土豆丝";
}
}
public interface FoodMaterial {
String getFood();
}
class Potato implements FoodMaterial{
@Override
public String getFood() {
return "酸辣土豆丝";
}
}
class Chicken implements FoodMaterial{
@Override
public String getFood() {
return "可乐鸡翅";
}
}
public class Cooker {
public void cook(FoodMaterial foodMaterial) {
System.out.println("开始做菜了");
System.out.println(foodMaterial.getFood());
}
public static void main (String []args) {
Cooker cooker = new Cooker();
cooker.cook(new Potato());
}
}
原文发布时间为:2018-08-25
本文作者:小小小咖